17070047 / 17070047/CodeStructureCourse

王玉鑫

Offen
#70 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
16
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

```c
#include
#include
#include
#define MAXSIZE 100

typedef struct {
int cardNum;
char name[8];
char major[10];
int classNum;
}libCardInfo;

typedef struct{
libCardInfo cardInfo;
}recordInfo;

typedef struct{
recordInfo r[MAXSIZE+1];
int length;
}table;

void input(table *tab){
char s='Y';
tab->length=1;
while(s=='Y'||s=='y'&&tab->length<=MAXSIZE){
printf("\n请输入借书卡卡号:");
scanf("%d",&tab->r[tab->length].cardInfo.cardNum);
printf("请输入持卡人姓名:");
scanf("%s",tab->r[tab->length].cardInfo.name);
printf("请输入持卡人系别:");
scanf("%s",tab->r[tab->length].cardInfo.major);
printf("请输入持卡人班号:");
scanf("%d",&tab->r[tab->length].cardInfo.classNum);
printf("是否继续录入?(Y/N):");
getchar();
scanf("%c",&s);
tab->length++;
}
}
void output(libCardInfo *info){
printf("\t \n");
printf("\t 借书证卡号:%d\n",info->cardNum);
printf("\t 持卡人姓名:%s\n",info->name);
printf("\t 持卡人系别:%s\n",info->major);
printf("\t 持卡人班号:%d\n",info->classNum);
printf("\t \n");
}

void shellinsertsort(table *tab){
int i,j,d;
d=tab->length/2;
while(d>=1){
for(i=d+1; ilength; i++){
tab->r[0]=tab->r[i];
j=i-d;
while(j>0&&tab->r[0].cardInfo.cardNumr[j].cardInfo.cardNum){
tab->r[j+d]=tab->r[j];
j=j-d;
}
tab->r[j+d]=tab->r[0];
}
d=d/2;
}
for(i=1; ilength; i++){
output(&tab->r[i].cardInfo);
}

}

void seqSearch(table *tab){
int i=1, j=1;
char major[10];
printf("\n请输入你要查找的系名:");
scanf("%s",major);
while(ilength){
if(!strcmp(tab->r[i].cardInfo.major,major)){
output(&(tab->r[i].cardInfo));
j=0;
}
i++;
}
if(j) printf("\t\t 『没有该系别的记录!』\n");
}

int main() {
int x, set;
table tab;
while(set){
printf("操作序号:");
printf("\n");
printf("1.录入借书证基本信息 \n");
printf("\n");
printf("2.输出已有借书证信息 \n");
printf("\n");
printf("3.系名查找借书证信息 \n");
printf("\n");
printf("4.退出借书证管理系统 \n");
printf("\n");
printf("操作选择:");
scanf("%d",&x);
switch(x){
case 1:input(&tab);break;
case 2:shellinsertsort(&tab);break;
case 3:seqSearch(&tab);break;
case 4:set=0;printf("系统退出成功!\n");break;
default: printf("没有该选项对应的操作!");
}
system("pause");
system("cls");
}
return 0;
}

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

The issue contains a full C program for a library card management system. Start by examining the main() function in the provided code to understand the menu structure. Look for logical errors in input handling, sorting (shellinsertsort), or search (seqSearch) functions. The task is to identify and fix bugs in this existing code, but the specific bug is not described. Run the program, test each menu option, and check for buffer overflows, incorrect array indexing, or sorting issues.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.