喵宅苑 MewoGarden × 技术宅社区II | Z站 Z Station 棒棒哒纯文字二次元技术社区

正文

新手求助,关于一个switch的跳出问题

作者:阳光闪闪
[i=s] 本帖最后由 阳光闪闪 于 2015-7-31 10:26 编辑 c primer plus 第七章第11道习题,用的是DEV c++, 我写出来后每次进入switch不管跳到哪个case最后都会强行走一遍default再转下一个循环。。。,试过把continue换成break还是依然跳不过这个default,公司写代码的同事都搞不定。。。求大神指教我问题出在哪里TAT int main(void) { char choice,choice2; int artichoke, beet, carrot, buy, tart, tbee, tcar,allmess; float allprice,fprice,tprice; tart = tbee = tcar = 0; printf("Please choose the product you want to buy:(q to quit,y to count)\n"); printf("a) artichoke b) beet c) carrot \n"); first:while((choice=getchar()) != 'q') { switch(choice) { case 'a': printf("How many pounds do you want to buy: \n"); scanf("%d", &buy); tart += buy; continue; case 'b': printf("How many pounds beet do you want to buy: \n"); scanf("%d", &buy); tbee += buy; continue; case 'c': printf("How many pounds carrot do you want to buy: \n"); scanf("%d", &buy); tcar += buy; continue; default: printf("You have enter the wrong number, please enter a, b, c, y or q. \n"); goto first; } printf("Do you want to buy more?\n"); goto first; } printf("Thank you!"); over:return 0; }

回复

0%
站点地图友情链接:
喵宅苑
喵空间社区程序
喵宅苑 静态版
宅喵RPG地图编辑器
络合兔
Lanzainc
技术宅
小五四博客
莉可POI
Mithril.js
枫の主题社
Project1
午后少年
机智库
七濑胡桃
xiuno
幻想の日常
魂研社
Nothentai
0xffff
欲望之花
泽泽社长
淀粉月刊
HAYOU
红客联盟
异次元
轻之国度
神奇宝贝新生代
游戏狗
口袋双子星
我的世界论坛
梦次元
动漫东东
动漫国际
精艺论坛
78动漫
吐槽弹幕网
漫客栈