17070047 / 17070047/CodeStructureCourse

1707004711贾剑利

Abierto
#82 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
#include
#include
#define m 20
#define maxsize 100
typedef struct
{
int key;
int card;
char name[m];
int num;
char department[m];
}recordtype;
typedef struct
{
recordtype r[maxsize+1];
int length;
}node;
node *create()
{
node *p;
int i;
p=(node *)malloc(sizeof(node));
printf ("输入学生个数:\n");
scanf ("%d",&p->length);
getchar();
p->r[0].card=0;
p->r[0].name[m]='\0';
p->r[0].num=0;
p->r[0].department[m]='\0';
printf ("输入学生的卡号,姓名,班号,系别:\n");
for (i=1;i<=p->length;i++)
{
scanf ("%d%s%d%s",&p->r[i].card,&p->r[i].name,&p->r[i].num,&p->r[i].department);
}
return p;
}
void quicksort(node *p,int left,int right)
{
int i,j;
if (leftr[0].card=p->r[i].card;
strcpy(p->r[0].name,p->r[i].name);
p->r[0].num=p->r[i].num;
strcpy(p->r[0].department,p->r[i].department);
do
{
while (p->r[j].card>p->r[0].card&&ir[i].card=p->r[j].card;
strcpy(p->r[i].name,p->r[j].name);
p->r[i].num=p->r[j].num;
strcpy(p->r[i].department,p->r[j].department);
i++;
}
while (p->r[i].cardr[0].card&&ir[j].card=p->r[i].card;
strcpy(p->r[j].name,p->r[i].name);
p->r[j].num=p->r[i].num;
strcpy(p->r[j].department,p->r[i].department);
j--;
}
}while (i!=j);
p->r[i].card=p->r[0].card;
strcpy(p->r[i].name,p->r[0].name);
p->r[i].num=p->r[0].num;
strcpy(p->r[i].department,p->r[0].department);
quicksort(p,left,i-1);
quicksort(p,i+1,right);
}
}
void display(node *p)
{
int i;
for (i=1;i<=p->length;i++)
{
printf ("%d ",p->r[i].card);
printf ("%s ",p->r[i].name);
printf ("%d ",p->r[i].num);
printf ("%s\n",p->r[i].department);
}
}
void search(node *p,char n[m])
{
int i;
for (i=1;i<=p->length;i++)
if (strcmp(p->r[i].department,n)==0)
printf ("%d %s %d %s\n",p->r[i].card,p->r[i].name,p->r[i].num,p->r[i].department);
}
int main()
{
node *p,*q;
int j,n;
char i[m];
p=(node *)malloc(sizeof(node));
q=(node *)malloc(sizeof(node));
printf ("----学生信息----\n");
p=create();
printf ("输入左右边界的下标值:\n");
scanf ("%d%d",&n,&j);
quicksort(p,n,j);
printf ("输出排序后的结果:\n");
display(p);
printf ("输入要查找的系别:\n");
scanf ("%s",&i);
getchar();
printf ("输出%s系别对应的学生信息:\n",i);
search(p,i);
return 0;
}
```
![n k0h9 usqw _mzal i](https://user-images.githubusercontent.com/45330202/49655995-22669300-fa77-11e8-9817-ae85016debb4.png)

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 with a quicksort implementation for student records. The problem is not described; the code may have bugs or be incomplete. Start by understanding the data structures in the code (recordtype, node) and the intended functionality. Run the program to see if it compiles and behaves as expected. Look for issues like buffer overflows, incorrect sorting, or memory leaks. The repository appears to be a coursework project, so check if there are any related instructions or tests.

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
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
10/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.