[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; }