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

4.10输出星期几的英文表示switch语句}#includevoidmain(){intn;scanf("%d",&n);switch(n){case1:printf("Monday\n");break;case2:printf("Tuesday\n");break;case3:printf("Wednesday\n");break;case4:printf("Thursday\n");break;case5:pr

题目详情
4.10 输出星期几的英文表示switch语句}#include void main() { int n; scanf("%d",&n); switch(n) { case1:printf("Monday\n");break; case2:printf("Tuesday\n");break; case3:printf("Wednesday\n");break; case4:printf("Thursday\n");break; case5:printf("Friday\n");break; case6:printf("Saturday\n");break; case7:printf("Sunday\n");break; default:printf("Error\n"); } }为什么我输入什么都显示Error 请大神赐教
▼优质解答
答案和解析
#include #include int main() { int n; scanf("%d",&n); switch(n) { case 1:printf("Monday\n");break; case 2:printf("Tuesday\n");break; case 3: printf("Wednesday\n");break; case 4:printf("Thursday\n");break; case 5:printf("Friday\n");break; case 6:printf("Saturday\n");break; case 7:printf("Sunday\n");break; default:printf("Error\n"); break; } system("pause"); return 0; } ----------------------------case 后面要加空格 例如: case 1:printf("Monday\n");break;