早教吧 育儿知识 作业答案 考试题库 百科 知识分享

关于switch语句求真相switch(m)\x05{\x05case1:head=create();gotoA;\x05case2:InsertPoint(head);gotoA;\x05case3:DelPoint(head);gotoA;\x05case4:print(head);gotoA;\x05case5:printf("Quit?\n");\x05\x05printf("YforYESelseforreturn\n");\x

题目详情
关于switch语句 求真相
switch(m)
\x05{
\x05case 1:head=create();goto A;
\x05case 2:InsertPoint(head);goto A;
\x05case 3:DelPoint(head);goto A;
\x05case 4:print(head);goto A;
\x05case 5:printf("Quit?\n");
\x05\x05printf("Y for YES else for return\n");
\x05\x05scanf("%c",&c);
\x05\x05if(c=='Y'||c=='y')
\x05\x05\x05exit (0);
\x05\x05else\x05goto A;
\x05default:printf("you chose wrong date\n");goto A;
\x05}为什么这段代码没有执行scanf 直接跳过scanf执行了goto
▼优质解答
答案和解析
不知道你前面还有没有类似scanf之类的输入函数,有的话就在case5 的scanf之前加一句
getchar();