17070047 / 17070047/CodeStructureCourse

王心如

Abierto
#83 0 comentarios 0 reacciones 0 asignados Ver en GitHub
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"
#include"stdlib.h"
#define MAXSIZE 100
typedef int keytype;
typedef struct{
keytype key; //学号
keytype ckey;//班级
char name[20];
}recordtype;
typedef struct{
recordtype r[MAXSIZE+1];
int length;
}table;
void quicksort(table *tab,int left,int right)
{
int i,j;
if(leftr[0]=tab->r[i];
do
{
while(tab->r[j].key>tab->r[0].key&&ir[i].key=tab->r[j].key ;
i++;
}
while(tab->r[i].keyr[0].key&&ir[j].key=tab->r[i].key;
j--;
}
}
while(i!=j);
tab->r[i]=tab->r[0];
quicksort(tab,left,i-1);
quicksort(tab,i+1,right);

}
}
void create(table *tab)
{
int j;
//tab=(table*)malloc(sizeof(table));
printf("请输入学生人数:\n");
scanf("%d",&tab->length);
printf("输入信息:\n") ;
for(j=1;j<=tab->length;j++)
{
printf("姓名:");
scanf("%s",&tab->r[j].name);
printf("班级:");
scanf("%d",&tab->r[j].ckey);
printf("学号:");
scanf("%d",&tab->r[j].key);
}
}
void print(table *tab)
{
printf("姓名\t\t");
printf("班级\t\t");
printf("学号\t\t\n");
for(int i=1;i<=tab->length;i++)
{
printf("%s\t\t",tab->r[i].name) ;
printf("%d\t\t",tab->r[i].ckey);
printf("%d\t\t\n",tab->r[i].key);
}
}
void choose()
{
printf("请选择操作\n") ;
printf("1:创建\n");
printf("2:排序\n");
printf("3:输出\n");
printf("4:查找\n");
}
void search(table *tab)
{
char na[20];
int j=0;
printf("输入要查找的姓名:");
scanf("%s",&na);
for(int i=1;i<=tab->length;i++)
{
if(!strcmp(na,tab->r[i].name))
{
printf("姓名\t\t");
printf("班级\t\t");
printf("学号\t\t\n");
printf("%s\t\t",tab->r[i].name) ;
printf("%d\t\t",tab->r[i].ckey);
printf("%d\t\t\n",tab->r[i].key);
j++;
}
}
if(!j)
{
printf("不存在");
}
}
int main()
{

int i;
table tab;
choose();
while(scanf("%d",&i)!=EOF)
{
switch(i)
{
case 1:create(&tab);
case 2:
quicksort(&tab,1,tab.length);break;
case 3:
print(&tab);break;
case 4:
search(&tab);break;
default:printf("请重新输入!");
}
choose();
}
return 0;
}
```

![49658941-1b8f4e80-fa7e-11e8-8dfb-5a3f7d73da55](https://user-images.githubusercontent.com/32426394/49683073-fb9d7080-faf9-11e8-9309-bdea97f73be9.png)

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 with a quicksort implementation that sorts student records by key (student ID). The bug likely involves the sorting logic or data handling, as the code is provided but the expected behavior isn't described. Start by examining the quicksort function in the provided code, particularly the swap operations and pivot handling. Run the program to see if it crashes or sorts incorrectly, then debug by checking array bounds and data assignments.

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
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.