17070047 / 17070047/CodeStructureCourse

张斌智

Aperta
#68 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
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;
}
}
}
```
![default](https://user-images.githubusercontent.com/45329547/49650376-f3482580-fa66-11e8-9eed-74ffc5309c1d.png)
![default](https://user-images.githubusercontent.com/45329547/49650384-fa6f3380-fa66-11e8-9c57-e0f50aa2b83d.png)
![default](https://user-images.githubusercontent.com/45329547/49650395-01964180-fa67-11e8-879e-86830eaff3f8.png)
![default](https://user-images.githubusercontent.com/45329547/49650403-06f38c00-fa67-11e8-8f56-776ae8485300.png)
![default](https://user-images.githubusercontent.com/45329547/49650411-0a871300-fa67-11e8-9cbc-4ab393f0fcd2.png)

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.