17070047 / 17070047/CodeStructureCourse

1707004715杨旭实验4

Open
#87 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16
Forks
2
PR merge metrics
No merged PRs in 30d

Description

```c

#include
#include
#include
#define MAXSIZE 100
typedef struct
{
int xuehao;
char name[20];
char xibie[20];
}node;
typedef struct
{
node a[MAXSIZE+1];
int len;
}table;
void init(table *s)
{
s->len=0;
}
void creat(table *s)
{
int i,d;
printf("请输入信息个数 ");
scanf("%d",&d);
printf("系别 学号 姓名\n");
for(i=1;i<=d;i++)
{
scanf("%s%d%s",&s->a[i].xibie,&s->a[i].xuehao,&s->a[i].name);
s->len++;
}
}
void display(table *s)
{
int i;
printf("系别 学号 姓名\n");
for(i=1;i<=s->len;i++)
{
printf("%s %d %s\n",s->a[i].xibie,s->a[i].xuehao,s->a[i].name);
}
}
table *quicksort(table *s,int left,int right)
{
int i,j;
if(lefta[0]=s->a[i];
do
{
while((s->a[j].xuehao>s->a[0].xuehao)&&ia[i]=s->a[j];
i++;
}
while((s->a[i].xuehaoa[0].xuehao)&&ia[j]=s->a[i];
j--;
}
}while(i!=j);
s->a[i]=s->a[0];
quicksort(s,left,i-1);
quicksort(s,i+1,right);
}
return s;
}
node erfen(table *s,char xibiek[20])
{
int low=1,high=s->len,mid;
while(low<=high)
{
mid=(low+high)/2;
if(strcmp(s->a[mid].xibie,xibiek)==0)
printf("%s %d %s\n",s->a[mid].xibie,s->a[mid].xuehao,s->a[mid].name);
if(strcmp(s->a[mid].xibie,xibiek)==1)
high=mid-1;
else
low=mid+1;
}
return;
}
void jiansuo(table *s,char xibiek[20])
{
int i;
printf("系别 学号 姓名\n");
for(i=1;i<=s->len;i++)
{
if(strcmp(s->a[i].xibie,xibiek)==0)
printf("%s %d %s\n",s->a[i].xibie,s->a[i].xuehao,s->a[i].name);
}
}
int main()
{
table *s,*p;
char a[20];
int i=0;
s=(table *)malloc(sizeof(table));
p=(table *)malloc(sizeof(table));
init(s);
creat(s);
printf("输入创建的学生借书证信息:\n");
display(s);
quicksort(s,1,s->len);
printf("输出排序后的借书证信息:\n");
display(s);
printf("请输入检索的系别名: ");
scanf("%s",&a);
erfen(s,a);
printf("请输入检索的系别名2: ");
scanf("%s",&a);
jiansuo(s,a);
return 0;
}
```c

![qq 20181208105848](https://user-images.githubusercontent.com/45688940/49681476-3e048480-fadd-11e8-98bb-b44a0283a7c4.png)
![qq 20181208105848](https://user-images.githubusercontent.com/45688940/49681478-4b217380-fadd-11e8-9697-cc407562ee6e.png)

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue contains a C program for managing student records with sorting and search functions. The problem is not described; the user posted code and images. To start, examine the provided code in the issue body for logical errors, memory leaks, or incorrect algorithm implementations (e.g., quicksort, binary search). Run the program to see its behavior and compare with expected output. The repository is a coursework project, so check if there are similar examples or specifications in other files.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
10/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.