b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

vs c语言图书管理系统课程设计_c语言图书管理系统课程设计报告_图书管理系统c语言程序设计

电脑杂谈  发布时间:2019-08-08 17:01:48  来源:网络整理

c语言图书管理系统课程设计报告_图书管理系统c语言程序设计_vs c语言图书管理系统课程设计

小学开了C语言的课,学了好久C语言了,所以水准还是很垃圾。但还是得学。今天拿出了学生的课堂设计报告要求。根据要求弄了半天,对着书上的题目,总算勉强弄出来一个小型书店管理功能。不管怎么说,这是我头一次自己写一个完整的有点功能的流程。也学到了不少的小常识。甚至在做完编译成功的时候还小有点成就感呢(刚写出来到流程,报出了N十来个错误,高手们不要拍我啊,哈哈)。

通过写了这一个程序,发现对于基础常识的理解真的很重要。比如数组参数及其传递,大局函数与局部函数,变量声明,函数的内存空间,还有对于各个函数的概念。没有真正吃透那些东西写的流程会多好多错误并且浪费时间,而明白了就会防止太多错误。

其实,自己动手写程序很重要。即使你看的再理解,在动手的时候仍可能会出些错误,这种错误有时是很小的vs c语言图书管理系统课程设计,譬如将==写成赋值字符,如果多些了一个“;”,这种都是第一次编写流程时稍不留意便会出现的。一旦多写些程序,提醒一下,这样错误便会很容易避免。而且编程序的过程应该综合利用自己所学知识的过程,在这之中可以发现自己的不足,加深对常识的理解。下面就是写的流程了。

**************************************************************************************************************

#include<stdio.h>

#include<stdlib.h>

#include<conio.h>

#include<string.h>

/*书的完全信息资料*/

struct book

{

char code[20];

char name[20];

char author[15];

char pub[20];

char pub_date[20];

float price;

long kucun; /*库存*/

}book[100];

int a=0;

float cg_money=0,xs_money=0;

void input(int i) /*输入图书基本资料*/

{

printf("input information of books:/n");

fflush(stdin);

printf("book code:");

gets(book[i].code);

printf("name:");

gets(book[i].name);

printf("author:");

gets(book[i].author);

printf("pub:");

gets(book[i].pub);

printf("pub_date:");

gets(book[i].pub_date);

printf("price:");

scanf("%f",&book[i].price);

printf("kucun:");

scanf("%ld",&book[i].kucun);

c语言图书管理系统课程设计报告_vs c语言图书管理系统课程设计_图书管理系统c语言程序设计

fflush(stdin);

}

extern int a;

void search(char scode[20]) /*查询图书函数*/

{ int i;

for(i=;i<=a;i++)

{

if(strcmp(scode,book[i].code)==)

{

printf("code:%s/n",book[i].code);

printf("name:%s/n",book[i].name);

printf("author:%s/n",book[i].author);

printf("pub:%s/n",book[i].pub);

printf("pub_date:%s/n",book[i].pub_date);

printf("price:%6.1f/n",book[i].price);

printf("kucun:%d/n",book[i].kucun);

break;

}

}

if(i==a+1)

{printf("Cannot find !/n");}

}

void cai(char code[20]) /*采购图书函数*/

{

float cg_price;

long cg_amount;

int i;

while(1)

{

for(i=;i<=a;i++)

{

if(strcmp(code,book[i].code)==)

{

printf("code:%s/n",book[i].code);

printf("name:%s/n",book[i].name);

printf("author:%s/n",book[i].author);

printf("pub:%s/n",book[i].pub);

printf("pub_date:%s/n",book[i].pub_date);

printf("price:%6.1f/n",book[i].price);

c语言图书管理系统课程设计报告_vs c语言图书管理系统课程设计_图书管理系统c语言程序设计

printf("kucun:%d/n",book[i].kucun);

break;

}

}

if(i==a+1)

{printf("Cannot find !/nPress key to redial.../n");

getch();

}

else break;

}

printf("cg_amount:");

scanf("%ld",&cg_amount);

printf("cg_price:");

scanf("%f",&cg_price);

cg_money=cg_amount*cg_price+cg_money;

book[i].kucun=book[i].kucun+cg_amount; fflush(stdin);

}

void sell(char code[20],long amount) /*收购图书函数*/

{

int i=0;

if(strcmp(code,book[i].code)==)

{

printf("%s",book[i].name);

if(amount<=book[i].kucun)

{

book[i].kucun=book[i].kucun-amount;

xs_money=xs_money+amount*book[i].price;

}

else

{

printf("kucun is not enough,%ld is left/n",book[i].kucun);

}

}

else {printf("Cannot find !/t Press any key to continue.../n");fflush(stdin);}

}

void main() /*主函数*/

{ char c,code[20];

int s,i=;

long amount;

图书管理系统c语言程序设计_c语言图书管理系统课程设计报告_vs c语言图书管理系统课程设计

while(1)

{ system("cls"); /*清屏*/

printf("1.input information of books/n2.search books/n3.buy books/n4.sell books/n5.profit/n6.exit/n");

printf("s=");

scanf("%d",&s);

switch(s)

{

case 1:i=a;

fflush(stdin);

input(i);

printf("continue?/n");

c=getchar();

while(c=='y'||c=='Y')

{

i++;

input(i);

printf("continue?/n");

c=getchar();

}

a=i+1;break; /*a baoliu shu zu jin xing dao nayige shu*/

case 2:fflush(stdin);printf("input searching code:");

gets(code);

search(code);

printf("continue?");

scanf("%c",&c);

while(c=='y'||c=='Y')

{ fflush(stdin);printf("input searching code:");

gets(code);

search(code);

printf("continue?");

scanf("%c",&c);

}

break;

case 3:fflush(stdin);

printf("input code:");

gets(code);

cai(code);

printf("continue?/n");

c=getch();

vs c语言图书管理系统课程设计_c语言图书管理系统课程设计报告_图书管理系统c语言程序设计

while(c=='y'||c=='Y')

{ fflush(stdin);

printf("input code:");

gets(code);

cai(code);

printf("continue?");

c=getch();

}

break;

case 4:fflush(stdin);printf("input code:");

gets(code);

printf("input amount:");

scanf("%ld",&amount); fflush(stdin);

sell(code,amount);

printf("continue?/n");

scanf("%c",&c);

while(c=='y'||c=='Y')

{ fflush(stdin);

printf("input code:");

gets(code);

printf("input amount:");

scanf("%ld",&amount);

sell(code,amount); fflush(stdin);

printf("continue?");

c=getchar();

}

break;

case 5:printf("Profit:%.2f/n",xs_money-cg_money);

getch();

break;

case 6:exit();

}

}

}

/*本流程竟然在Turbo C中能正常运行,但在VC中出现了几个错误;

进行了一下改正:1.将clrscr();去掉或者换成system(“cls”);

原因是,两者是TC中特有的。

2.提高了几个头文件vs c语言图书管理系统课程设计,#include<string.h>是因为:strcmp;

3.提高了#include<conio.h>是因为:getch();

因为头文件没有加出现的错误是:undeclared identifier


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-118511-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...