17070047 / 17070047/CodeStructureCourse

1707004711贾剑利

Đang mở
#82 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
16
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

```c
#include
#include
#include
#define m 20
#define maxsize 100
typedef struct
{
int key;
int card;
char name[m];
int num;
char department[m];
}recordtype;
typedef struct
{
recordtype r[maxsize+1];
int length;
}node;
node *create()
{
node *p;
int i;
p=(node *)malloc(sizeof(node));
printf ("输入学生个数:\n");
scanf ("%d",&p->length);
getchar();
p->r[0].card=0;
p->r[0].name[m]='\0';
p->r[0].num=0;
p->r[0].department[m]='\0';
printf ("输入学生的卡号,姓名,班号,系别:\n");
for (i=1;i<=p->length;i++)
{
scanf ("%d%s%d%s",&p->r[i].card,&p->r[i].name,&p->r[i].num,&p->r[i].department);
}
return p;
}
void quicksort(node *p,int left,int right)
{
int i,j;
if (leftr[0].card=p->r[i].card;
strcpy(p->r[0].name,p->r[i].name);
p->r[0].num=p->r[i].num;
strcpy(p->r[0].department,p->r[i].department);
do
{
while (p->r[j].card>p->r[0].card&&ir[i].card=p->r[j].card;
strcpy(p->r[i].name,p->r[j].name);
p->r[i].num=p->r[j].num;
strcpy(p->r[i].department,p->r[j].department);
i++;
}
while (p->r[i].cardr[0].card&&ir[j].card=p->r[i].card;
strcpy(p->r[j].name,p->r[i].name);
p->r[j].num=p->r[i].num;
strcpy(p->r[j].department,p->r[i].department);
j--;
}
}while (i!=j);
p->r[i].card=p->r[0].card;
strcpy(p->r[i].name,p->r[0].name);
p->r[i].num=p->r[0].num;
strcpy(p->r[i].department,p->r[0].department);
quicksort(p,left,i-1);
quicksort(p,i+1,right);
}
}
void display(node *p)
{
int i;
for (i=1;i<=p->length;i++)
{
printf ("%d ",p->r[i].card);
printf ("%s ",p->r[i].name);
printf ("%d ",p->r[i].num);
printf ("%s\n",p->r[i].department);
}
}
void search(node *p,char n[m])
{
int i;
for (i=1;i<=p->length;i++)
if (strcmp(p->r[i].department,n)==0)
printf ("%d %s %d %s\n",p->r[i].card,p->r[i].name,p->r[i].num,p->r[i].department);
}
int main()
{
node *p,*q;
int j,n;
char i[m];
p=(node *)malloc(sizeof(node));
q=(node *)malloc(sizeof(node));
printf ("----学生信息----\n");
p=create();
printf ("输入左右边界的下标值:\n");
scanf ("%d%d",&n,&j);
quicksort(p,n,j);
printf ("输出排序后的结果:\n");
display(p);
printf ("输入要查找的系别:\n");
scanf ("%s",&i);
getchar();
printf ("输出%s系别对应的学生信息:\n",i);
search(p,i);
return 0;
}
```
![n k0h9 usqw _mzal i](https://user-images.githubusercontent.com/45330202/49655995-22669300-fa77-11e8-9817-ae85016debb4.png)

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

The issue contains a C program with a quicksort implementation for student records. The problem is not described; the code may have bugs or be incomplete. Start by understanding the data structures in the code (recordtype, node) and the intended functionality. Run the program to see if it compiles and behaves as expected. Look for issues like buffer overflows, incorrect sorting, or memory leaks. The repository appears to be a coursework project, so check if there are any related instructions or tests.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
10/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.