17070047 / 17070047/CodeStructureCourse

1607094126李然

Open
#91 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"stdio.h"
#include"stdlib.h"
#include"string.h"
#define m 20
#define max 100
typedef struct studentnode{
char cardnum[m];
char name[m];
char classnum[m];
char college[m];
}node;
typedef struct{
node r[max+1];
int length;
}table;
void sort(table *tab,int left,int right)
{
int i,j;
if(leftr[0]=tab->r[i];
do
{
while(strcmp(tab->r[j].cardnum,tab->r[0].cardnum)==1&&ir[i]=tab->r[j];
i++;
}
while(strcmp(tab->r[i].cardnum,tab->r[0].cardnum)==-1&&ir[j]=tab->r[i];j--;}
}while(i!=j);
tab->r[i]=tab->r[0];
sort(tab,left,i-1);
sort(tab,i+1,right);
}
}
void creat(table *tab)
{
int i,j,k;
printf("请输入结点个数:\n");
scanf("%d",&tab->length);
tab->length++;
getchar();
for(i=1;ilength;i++)
{
printf("请输入卡号:\n");
gets(tab->r[i].cardnum);
printf("请输入名字:\n");
gets(tab->r[i].name);
printf("请输入班号:\n");
gets(tab->r[i].classnum);
printf("请输入系别:\n");
gets(tab->r[i].college);
printf("\n");
}
printf("创建完成\n");
}
void find(table *tab)
{
int i,j;
char object[m];
printf("请输入你要查找的系别:\n");
gets(object);
for(i=1;ilength;i++)
{
if(strcmp(object,tab->r[i].college)==0)
{
puts(tab->r[i].cardnum);
puts(tab->r[i].name);
puts(tab->r[i].classnum);
puts(tab->r[i].college);
printf("\n");
}
}
}
void display(table *tab)
{
int i;
for(i=1;ilength;i++)
{
puts(tab->r[i].cardnum);
puts(tab->r[i].name);
puts(tab->r[i].classnum);
puts(tab->r[i].college);
printf("\n");
}
}
int main()
{
int i;
table *tab;
tab=(table *)malloc(sizeof(table));
creat(tab);
sort(tab,1,tab->length-1);
display(tab);
while(scanf("%d",&i)!=EOF)
{
getchar();
find(tab);
}
return 0;
}
```
![n ow k8iy5 c 8_s9w2](https://user-images.githubusercontent.com/45333240/49684481-791fab80-fb0f-11e8-9b5d-5c22d2282542.png)
![oyhqj z gm0jbv d991ezl2](https://user-images.githubusercontent.com/45333240/49684482-79b84200-fb0f-11e8-96a1-020bc5980514.png)
![7w01o oxuzu o7qq0hzo qe](https://user-images.githubusercontent.com/45333240/49684483-79b84200-fb0f-11e8-8917-ace9206da02e.png)
![nov7 z y00kaq0iwba 5ffn](https://user-images.githubusercontent.com/45333240/49684484-7a50d880-fb0f-11e8-8640-fd516f87dbc9.png)

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue contains a C program with a student record management system. The code includes struct definitions, a quicksort implementation, and functions for creating, finding, and displaying records. The images are broken links. To understand the bug, examine the sort function's use of strcmp return values and the array indexing starting at 1. Run the program to see if it crashes or produces incorrect output. Check for memory leaks and buffer overflows in the input handling.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.