17070047 / 17070047/CodeStructureCourse

张斌智

オープン
#68 コメント 0 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。