17070047 / 17070047/CodeStructureCourse
赵玉洁
- 主要言語
- C++
- スター
- 16
- フォーク
- 2
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
# 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

コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
The issue shows a C program for sorting and searching student records. The code includes a QuickSort implementation and a search function. Start by examining the main function in the provided code to understand the data flow. Look for potential bugs in the sorting logic or input handling, and run the program to reproduce the issue shown in the image. Check for memory issues, off-by-one errors in array indexing (since it uses 1-based indexing), and ensure string comparisons work correctly.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c
- 領域
- cli
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100