17070047 / 17070047/CodeStructureCourse
赵玉洁
- Dominant language
- C++
- Stars
- 16
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
# 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

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.