|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 爱喝的三明治 于 2022-11-10 23:34 编辑
printf不输出数据
问题出在133和138行之间无线循环
无法输出
在查询这个功能里没办法输出数据
实在是找不到问题在哪里,没有一点头绪
- #include <stdio.h>
- #include<string.h>
- #include <stdlib.h>
- struct Goods
- {
- int id;//产品编号
- char kudan1;//入库单号
- char kudan2;//出库单号
- char name;//名称
- int num;//数量
- float cost;//成本
- float price;//售价
- float profit;//利润
-
- }goods[50],rk[20],ck[20],cx[90];
- void input();
- void output();
- void search();
- void menu();
- int main(){
- int command = 0; //command用于存储管理员命令对应的菜单数字
- int a = 1; //用于判断是否退出系统
- while(a){ //利用while循环实现对管理系统进行多种操作
- printf("请输入操作对应的数字!如需退出,请输入5!\n\n");
- scanf("%d", &command);
- switch(command){
- case(1): //进库
- input();
- break;
- case(2): //出库
- output();
- break;
- case(3): //查询库存
- search();
- break;
-
- default:
- printf("请输入正确的数字!\n\n"); //提示管理员重新输入正确的菜单数字
- break;
- }
- }
- printf(" 从"); //提示管理员成功退出系统
- return 0;
- }
- int S=0;//产品种类
- void input()//入库
- {
- int a,i=0,j=0;
- printf("请输入入库产品种类:\n");
- scanf("%d",&a);
- for(j=0;j<a;j++)
- { printf("请输入第%d个产品信息\n",(j+1));
- printf("产品名称:");
- scanf("%s",&goods[i].name);
- printf("产品编号:");
- scanf("%d",&goods[i].id);
- printf("例:2022年1月填为202201\n");
- printf("入库单号:\n");
- scanf("%s",&goods[i].kudan1);
- printf("数量:");
- scanf("%d",&goods[i].num);
- printf("请再输入一次\n");
- scanf("%d",&rk[i].num);
- int flag = 0;
- for(i = 0; i <S; i++)
- {
- if(rk[i].id==goods[i].id)
- {flag = 1;
- goods[i].num =rk[i].num+goods[i].num;
- break;
- }
- }
- if (flag == 0)
- {
- S++;
- }
- }
- }
- void output()//出库
- {
- }
- void search()
- {
- int i,s,flag;
- printf("1.查询入库单\n");
- printf("2.查询出库单\n");
- printf("3.退出菜单\n");
- while(1){
- printf("请选择编号:");
- scanf("%d",&s);
- flag=0;
- switch(s){
- case 1:
- printf("请输入要查询入库单号:\n");
- scanf("%d",&cx[i].kudan1);
- for(i=0;i<S;i++)
- if(goods[i].kudan1==cx[i].kudan1) {
- flag=1;
- printf("入库单号 编号 名称 数量 成本\n");
- printf("%d%d%s%d%f\n",goods[1].kudan1,goods[i].id ,goods[i].name ,goods[i].num ,goods[i].cost);}
- if(flag=0)
- printf("该单号不存在!\n");
- break;
- case 2:
- printf("请输入要查询出库单号:\n");
- scanf("%d",&cx[i].kudan2);
- for(i=0;i<S;i++)
- if(goods[i].kudan2==cx[i].kudan2){
- flag=1;
- printf("出库单号 编号 名称 数量 利润\n");
- goods[i].profit=goods[i].price-goods[i].cost;
- printf("%d%d%s%d%f\n",goods[1].kudan2,goods[i].id ,goods[i].name ,goods[i].num ,goods[i].profit);}
- if(flag=0)
- printf("该单号不存在!\n");
- break;
- case 3:
- return;
- default:
- printf("ddd");
- break;
- }
- }
- }
-
复制代码 |
|