17070047 / 17070047/CodeStructureCourse

张斌智

Ouverte
#68 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
16
Forks
2
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

```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)

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
c
Domaine
cli
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
20/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.