c语言实践大作业,要程序

时间:878次浏览2018.12.11提问

c语言实践大作业,要程序

已解决问题

hao231知道平台可亲可爱的Erin`网友在878次浏览2018.12.11提问提了关于IT技术教育培训编程相关的问题,他的提问有没有c语言实践大作业,要程序IT技术教育培训编程希望大家能够帮助她。

详细问题描述及疑问:期待您的答案,感谢你,我会记得你对我的好的 !

第1个回答

随风2018.12.11回答提问者采纳#include<stdio.h>#include<stdlib.h>structDevice{intnumber;charname[100];charfactory[100];chardate[10];intnum;doubleprice;};typedefstructqueue{structDevicedevice;structqueue*next;}LinkList;LinkList*head,*end;voidcatalog();intcompare(char*s1,char*s2){inti=0;while(s1[i]!='\0'&&s2[i]!='\0'){if(s1[i]!=s2[i])return0;i++;}returns1[i]==s2[i]1:0;}voidview(){printf("设备号名称生产厂家购买日期数量价格\n");LinkList*p=head;while(p!=NULL){printf("%d%s%s%s%d%lf\n",p->device.number,p->device.name,p->device.factory,p->device.date,p->device.num,p->device.price);p=p->next;}printf("\n");catalog();}voidadd(){LinkList*p;intn;while(1){p=(LinkList*)malloc(sizeof(LinkList));printf("请输入设备号:\n");scanf("%d",&p->device.number);printf("请输入名称:\n");scanf("%s",p->device.name);printf("请输入生产厂家:\n");scanf("%s",p->device.factory);printf("请输入生产日期:\n");scanf("%s",p->device.date);printf("请输入数量:\n");scanf("%d",&p->device.num);printf("请输入价格:\n");scanf("%lf",&p->device.price);p->next=NULL;if(head==NULL){head=p;end=p;}else{end->next=p;end=p;}printf("数据保存成功,请选择下一步操作:\n");printf("(1)继续增加\n");printf("(0)返回\n");scanf("%d",&n);if(n!=1)break;}catalog();}voidupdate(){LinkList*p;intnumber;while(1){printf("请输入设备号:\n");scanf("%d",&number);p=head;while(p!=NULL){if(p->device.number==number){break;}p=p->next;}if(p==NULL){printf("未找到您输入设备号!\n");}else{printf("请输入名称:\n");scanf("%s",p->device.name);printf("请输入生产厂家:\n");scanf("%s",p->device.factory);printf("请输入生产日期:\n");scanf("%s",p->device.date);printf("请输入数量:\n");scanf("%d",&p->device.num);printf("请输入价格:\n");scanf("%lf",&p->device.price);printf("数据保存成功,请选择下一步操作:\n");}printf("(1)继续修改\n");printf("(0)返回\n");scanf("%d",&number);if(number!=1)break;}catalog();}voidquery(){intn;doublemin,max;charname[100];LinkList*p;while(1){printf("请选择查询方式:\n");printf("(1)根据设备名称\n");printf("(2)根据价格区间\n");scanf("%d",&n);p=head;if(n==1){printf("请输入设备名称\n");scanf("%s",name);printf("设备号名称生产厂家购买日期数量价格\n");while(p!=NULL){if(compare(p->device.name,name)){printf("%d%s%s%s%d%lf\n",p->device.number,p->device.name,p->device.factory,p->device.date,p->device.num,p->device.price);}p=p->next;}}else{printf("请输入价格区间\n");scanf("%lf%lf",&min,&max);printf("设备号名称生产厂家购买日期数量价格\n");while(p!=NULL){if(p->device.price>=min&&p->device.price<=max){printf("%d%s%s%s%d%lf\n",p->device.number,p->device.name,p->device.factory,p->device.date,p->device.num,p->device.price);}p=p->next;}}printf("(1)继续查询\n");printf("(0)返回\n");scanf("%d",&n);if(n!=1)break;}catalog();}voidcatalog(){printf("(1)浏览数据\n");printf("(2)增加数据\n");printf("(3)修改数据\n");printf("(4)查询\n");printf("(5)退出\n");printf("请选择操作序号:");intn;scanf("%d",&n);switch(n){case1:view();break;case2:add();break;case3:update();break;case4:query();break;case5:break;default:catalog();}}intmain(){head=end=NULL;catalog();return0;}