17070047 / 17070047/CodeStructureCourse

段玉兰

Đang mở
#67 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"stdio.h"
#include"string.h"
#define maxsize 1000
typedef struct{
char name[30];
char classnumber[30];
char card[30];
char department[30];
}library;
typedef struct{
library a[maxsize];
int len;
}seqlist;
/*创建*/
seqlist create()
{
seqlist t;
int i,n;
t.len=0;
printf("请输入要录入的信息个数:");
scanf("%d",&n);
t.len=n;
printf("请依次输入姓名、系别、班号、卡号:\n");
for(i=1;i<=n;i++)
{
scanf("%s",&t.a[i].name);
scanf("%s",&t.a[i].department);
scanf("%s",&t.a[i].classnumber);
scanf("%s",&t.a[i].card);
}
return t;
}
/*检索*/
void seqsearch(seqlist p)
{
int k,i;
k=p.len;
char key[8];
printf("请输入要检索的系别:\n");
scanf("%s",&key);
printf("----------------------------");
for(i=1;i<=k;i++)
{
if(strcmp(p.a[i].department,key)==0)
{
printf("\n%s ",p.a[i].name);
printf("%s ",p.a[i].department);
printf("班号:%s ",p.a[i].classnumber);
printf("卡号:%s \n",p.a[i].card);
}
}
}
/*快排*/
seqlist *quicksort(seqlist *seq,int left,int right)
{
int i,j,l;
if(lefta[0]=seq->a[i];
do{
while(strcmp(seq->a[j].card,seq->a[0].card)==1&&ia[i]=seq->a[j];
i++;
}
while(strcmp(seq->a[i].card,seq->a[0].card)<0&&ia[j]=seq->a[i];
j--;
}
}while(i!=j);

seq->a[i]=seq->a[0];
quicksort(seq,left,i-1);
quicksort(seq,i+1,right);
}
return seq;
}
int main()
{
int i,n,left,right,l;
seqlist p,*seq;
p=create();
right=p.len;
left=1;
seq=&p;
seqsearch(p);
printf("-----------------------------");
printf("\n按卡号排序的结果如下:\n");
seq=quicksort(seq,left,right);
printf("姓名: 系别: 班号: 卡号:\n");
for(l=1;l<=right;l++)
{

printf("%s ",seq->a[l].name);
printf("%14s ",seq->a[l].department);
printf("%16s ",seq->a[l].classnumber);
printf("%16s \n\n",seq->a[l].card);
}
return 0;
}
```

default

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 shows a C program for a library management system with a quicksort function that likely has a bug in the comparison logic (strcmp usage). Start by examining the quicksort function in the provided code, particularly the strcmp comparisons and the pivot handling. Run the program to see the sorting output, then debug by checking array indices and string comparisons. The goal is to fix the sorting so it correctly orders records by card number.

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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/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.