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"stdlib.h"
#include"string.h"
#define m 20
#define max 100
typedef struct studentnode{
char cardnum[m];
char name[m];
char classnum[m];
char college[m];
}node;
typedef struct{
node r[max+1];
int length;
}table;
void sort(table *tab,int left,int right)
{
int i,j;
if(leftr[0]=tab->r[i];
do
{
while(strcmp(tab->r[j].cardnum,tab->r[0].cardnum)==1&&ir[i]=tab->r[j];
i++;
}
while(strcmp(tab->r[i].cardnum,tab->r[0].cardnum)==-1&&ir[j]=tab->r[i];j--;}
}while(i!=j);
tab->r[i]=tab->r[0];
sort(tab,left,i-1);
sort(tab,i+1,right);
}
}
void creat(table *tab)
{
int i,j,k;
printf("请输入结点个数:\n");
scanf("%d",&tab->length);
tab->length++;
getchar();
for(i=1;ilength;i++)
{/*
printf("请输入卡号:\n");
gets(tab->r[i].cardnum);
printf("请输入名字:\n");
gets(tab->r[i].name);
printf("请输入班号:\n");
gets(tab->r[i].classnum);
printf("请输入系别:\n");
gets(tab->r[i].college);
printf("\n");*/
printf("请输入卡号:\t\t请输入名字:\t\t请输入班号:\t\t请输入系别:\n");
scanf("%s%s%s%s",tab->r[i].cardnum,tab->r[i].name,tab->r[i].classnum,tab->r[i].college);
}
printf("创建完成\n");
}
void find(table *tab)
{
int i,j;
char object[m];
printf("请输入你要查找的系别:\n");
gets(object);
for(i=1;ilength;i++)
{
if(strcmp(object,tab->r[i].college)==0)
{
printf("卡号:\t\t名字:\t\t班号:\t\t系别:\n");
printf("%s\t%s\t\t%s\t%s",tab->r[i].cardnum,tab->r[i].name,tab->r[i].classnum,tab->r[i].college);
}
}
}
void display(table *tab)
{
int i;
for(i=1;ilength;i++)
{
printf("卡号:\t\t名字:\t\t班号:\t\t系别:\n");
printf("%s\t%s\t\t%s\t%s",tab->r[i].cardnum,tab->r[i].name,tab->r[i].classnum,tab->r[i].college);
}
}
int main()
{
int i;
table *tab;
tab=(table *)malloc(sizeof(table));
creat(tab);
sort(tab,1,tab->length-1);
display(tab);
while(scanf("%d",&i)!=EOF)
{
getchar();
find(tab);
}
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 contains a C program for managing student records with sorting and search functions. The bug is not explicitly stated, but the code may have issues with input handling, memory allocation, or sorting logic. Start by compiling and running the program to see if it crashes or produces incorrect output. Examine the sort function's use of strcmp return values (1, -1) which may not be portable, and check for buffer overflows in scanf calls. The main entry point is the main() function; test with sample data to verify the sorting and search by college work correctly.
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