17070047 / 17070047/CodeStructureCourse
赵玉洁
- Lenguaje dominante
- C++
- Estrellas
- 16
- Forks
- 2
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
# Code
```C
#include
#include
#define MAXSIZE 100
typedef struct
{
int no;//序号
long key;//卡号
char xi[50];//系号
char name[50];//名字
int classes;//班级
}recordtype;
typedef struct
{
recordtype r[MAXSIZE];
int length;
}table;
void QuickSort(table *tab,int left,int right)
{
int i,j;
if(leftr[0]=tab->r[i];
do
{
while(ir[j].key>tab->r[0].key) j--;
if(ir[i]=tab->r[j];
i++;
}
while(ir[i].keyr[0].key) i++;
if(ir[j]=tab->r[i];
j--;
}
}
while(i!=j);
tab->r[i]=tab->r[0];
QuickSort(tab,left,i-1);
QuickSort(tab,i+1,right);
}
}
void creat(table *g)
{
int i,j=1;
printf("输入i,不等于一千可以持续输入\n");
scanf("%d",&i);
g->length=0;
while(i!=1000)
{
g->r[j].no = j;
printf("输入卡号\n");
scanf("%ld",&g->r[j].key);
printf("输入姓名\n");
scanf("%s",&g->r[j].name);
printf("输入系别\n");
scanf("%s",&g->r[j].xi);
printf("输入班级\n");
scanf("%d",&g->r[j].classes);
g->length++;
j++;
printf("输入i,不等于一千可以持续输入\n");
scanf("%d",&i);
}
}
void search(table *l)
{
int k,i;
k=l->length;
char finding[8];
printf("输入要检索的系别;\n");
scanf("%s",&finding);
for(i=1;i<=k;i++)
{
if(strcmp(l->r[i].xi,finding)==0)
{
printf("%d\n",l->r[i].key);
}
}
}
void main()
{
table tab;
int i;
creat(&tab);
QuickSort(&tab,1,tab.length);
printf("学号 姓名 系别 班级 \n");
for(i=1;i<=tab.length;i++)
{
printf("%ld %s %s %d\n",tab.r[i].key,tab.r[i].name,tab.r[i].xi,tab.r[i].classes);
}
search(&tab);
}
```
# Result

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 sorting and searching student records. The code includes a QuickSort implementation and a search function. Start by examining the main function in the provided code to understand the data flow. Look for potential bugs in the sorting logic or input handling, and run the program to reproduce the issue shown in the image. Check for memory issues, off-by-one errors in array indexing (since it uses 1-based indexing), and ensure string comparisons 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