17070047 / 17070047/CodeStructureCourse

1707004711贾剑利

オープン
#82 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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;
}
```
![n k0h9 usqw _mzal i](https://user-images.githubusercontent.com/45330202/49655995-22669300-fa77-11e8-9817-ae85016debb4.png)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。