17070047 / 17070047/CodeStructureCourse
段玉兰
- 主要语言
- C++
- 星标
- 16
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
描述
```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;
}
```
贡献指南
这个仓库没有索引到贡献指南
调研方向
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.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100