17070047 / 17070047/CodeStructureCourse
1707004711贾剑利
- 主要语言
- C++
- 星标
- 16
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
描述
```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;
}
```

贡献指南
这个仓库没有索引到贡献指南
调研方向
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.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 10/100