17070047 / 17070047/CodeStructureCourse

张斌智

未关闭
#68 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
16
派生
2
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

调研方向

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.

由索引模型根据 Issue 内容生成。

评估

技术栈
c
领域
cli
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。