17070047 / 17070047/CodeStructureCourse
张斌智
- Lingua principale
- C++
- Stelle
- 16
- Fork
- 2
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
```c
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "Windows.h"
#include "String.h"
#define d 10
typedef struct borrow
{
char stid[11];
char name[11];
char clss[11];
}lend;
typedef struct
{
int n;
lend b[d];
}node;
void init(node *p)
{
p->n = 0;
}
void Menu()
{
printf("\n\n\t*************************\n");
printf("\t**********主页面*********\n\n");
printf("\t*按c录入信息\n");
printf("\t*按n查找\n");
printf("\t*按a查看全部信息\n");
}
void creat(node *p)
{
char g[11];
int i = 0;
system("cls");
printf("\n\n\t**********创建*********\n\n");
printf(" *您正在创建,按#停止。*");
while(1)
{
printf("\n 请输入姓名:");
gets(g);
if(!strcmp(g,"#"))
break;
strcpy(p->b[i].name, g);
printf(" 请输入借书卡号:");
gets(g );
if(!strcmp(g,"#"))
break;
strcpy(p->b[i].stid, g);
printf(" 请输入班级号:");
gets(g );
if(!strcmp(g,"#"))
break;
strcpy(p->b[i++].clss, g);
}
p->n = i;
s(p, 0, i-1);
printf(" \n按卡号前两位排序后结果如下:\n");
seekall(*p,0);
}
void seek(node p)
{
char g[11];
int i = 0;
system("cls");
printf("\n\n\t**********查找*********\n\n");
printf(" 请输入要查找的卡号:");
gets(g);
while(1)
{
if(!strcmp(g,p.b[i].stid))
{
printf("\n 卡号\t姓名\t班级\n");
printf(" %s\t%s\t%s\n", p.b[i].stid, p.b[i].name, p.b[i].clss);
break;
}
if(i >= p.n)
{
printf("\n 该卡号不存在!!");
break;
}
i++;
}
}
int seekall(node p,int t)
{
char g[11];
int i = 0;
if(t)
{
system("cls");
printf("\n\n\t**********查找*********\n\n");
printf(" 信息如下:\n");
}
printf("\n 卡号\t姓名\t班级\n");;
if(p.b == 0)
printf(" \n\n无信息!!!\n");
else
while(i < p.n)
{
printf(" %s\t%s\t%s\n", p.b[i].stid, p.b[i].name, p.b[i].clss);
i++;
}
printf(" \n按任意键返回!");
getch();
return 0;
}
void seekx(node p)
{
char g[11];
int i = 0;
system("cls");
printf("\n\n\t**********查找*********\n\n");
printf(" 请输入要查找院系的卡号关键词:");
gets(g);
printf(" 信息如下:\n \n卡号\t姓名\t班级\n");
while(1)
{
if(!strncmp(g,p.b[i].stid,2))
{
printf(" %s\t%s\t%s\n", p.b[i].stid, p.b[i].name, p.b[i].clss);
}
if(i >= p.n)
{
break;
}
i++;
}
printf(" \n按任意键返回!");
getch();
}
int s(node *p, int left, int right)
{
node q;
int i, j;
if(leftb[i];
do
{
while(strcmp(p->b[j].stid, q.b[0].stid )>0&&i < j)
j--;
if(i < j)
{
p->b[i] = p->b[j];
i++;
}
while(strcmp(p->b[i].stid, q.b[0].stid )<0&&i < j)
i++;
if(i < j)
{
p->b[j] = p->b[i];
j--;
}
}while(i != j);
p->b[i] = q.b[0];
s(p, left, i - 1);
s(p, i +1, right);
}
return 0;
}
int main()
{
node p;
char g;
init(&p);
while(1)
{
system("cls");
Menu();
g = getch();
switch(g)
{
case 'c':case 'C':
creat(&p);
break;
case 'n':case 'N':
seekx(p);
break;
case 'a':case 'A':
seekall(p,1);
break;
default:
break;
}
}
}
```





Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
The issue contains a full C program for a library borrowing system with screenshots, but no description of the problem. A newcomer would need to understand the intended behavior, run the code, and identify bugs from unspecified symptoms. Start by compiling and testing the provided code to see if it crashes or produces incorrect output. Examine the sorting function `s` and the input handling for potential buffer overflows or logic errors.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 20/100