17070047 / 17070047/CodeStructureCourse
李祎凡
- 主要语言
- C++
- 星标
- 16
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
描述
```c
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#define m 100
typedef struct link_node{
char number[m];
char name[m];
char xi[m];
char classnumber[m];
}node;
typedef struct link_table{
node r[m];
}table;
table *create(int n)
{
table *tab=(table *)malloc(sizeof(table));
char number[20],xi[20],classnumber[20];
char name[10];
int i=1;
printf("please input name,number,xi and classnumber:\n");
while(i<=n)
{
scanf("%s%s%s%s",name,number,xi,classnumber);
strcpy(tab->r[i].name,name);
strcpy(tab->r[i].number,number);
strcpy(tab->r[i].xi,xi);
strcpy(tab->r[i].classnumber,classnumber);
i++;
}
return tab;
}
table *quicksort(table *tab,int left,int right)
{
int i,j;
if(leftr[0]=tab->r[i];
do
{
while(strcmp(tab->r[j].number,tab->r[0].number)==1&&ir[i]=tab->r[j];
i++;
}
while(strcmp(tab->r[i].number,tab->r[0].number)==-1&&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);
}
return tab;
}
void search(table *tab,char y[],int n)
{
int i=n;
printf("姓名 卡号 系名 班号 \n");
while(i>0)
{
if(strcmp(tab->r[i].xi,y)==0)
{
printf("%5s%15s%15s%15s\n",tab->r[i].name,tab->r[i].number,tab->r[i].xi,tab->r[i].classnumber);
i--;
}
else i--;
}
}
void display(table *tab,int n)
{
int i=1;
printf("姓名 卡号 系名 班号 \n");
while(i<=n)
{
printf("%5s%15s%15s%15s\n",tab->r[i].name,tab->r[i].number,tab->r[i].xi,tab->r[i].classnumber);
i++;
}
}
int main()
{
int n,left,right;
char y[20];
printf("please input n:\n");
scanf("%d",&n);
left=1;right=n;
table *tab,*tab1;
tab=create(n);
tab1=quicksort(tab,left,right);
printf("按卡号排序结果是:\n");
display(tab1,n);
printf("please input xi:\n");
scanf("%s",y);
search(tab,y,n);
return 0;
}
```

贡献指南
这个仓库没有索引到贡献指南
调研方向
The issue contains a C program for student record management with sorting and search functions. The screenshot likely shows a runtime error or incorrect output. Start by compiling and running the code to reproduce the issue. Examine the quicksort implementation for potential off-by-one errors, as array indices start at 1. Check string comparisons and memory usage. The main entry point is the main() function; test with sample input to verify sorting and search behavior.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100