17070047 / 17070047/CodeStructureCourse
段玉兰
- Lenguaje dominante
- C++
- Estrellas
- 16
- Forks
- 2
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
```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;
}
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- c
- Área
- cli
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100