case 7: printf("Sunday\n"); break; default: printf("输入的数字不在范围内\n"); break; } return 0; } 理解switch语句的用法,以及如何根据输入的数字输出对应的英文形式的星期。本题需要使用switch语句根据输入的数字选择对应的英文形式的星期进行输出。根据输入的数字,使用不同的case分支来输出...
a = input('请输入数字:') if a == '1': print('星期一') elif a ... a == '4': print('星期四') elif a == '5': print('星... 从键盘输入1~7(否则应给出出错信息)之间的数字,输出表示一个星期中对应某一天的英文单词。 #include <stdio.h> #define DAYS_OF_WEEK 7 char 新区传奇...
include <stdio.h> define DAYS_OF_WEEK 7 char *day[DAYS_OF_WEEK] = { "monday","tuesday","wendsday","thirsday","friday","saturday","sunday"};int main(void){ int i;scanf("%d", &i);if (i < 1 || i > DAYS_OF_WEEK){ printf("You've entered a wrong day\n");...
case 7:printf("7 SUNDAY");break;default:puts("error");} } } includevoid main(){ int a; printf("请输入整数:"); scanf("%d",a); switch(a){ case 1: printf("星期一");break; case 2: printf("星期二");break; case 3: printf("星期三");break; case 4: printf("星期四");break;...
输入一个数字(1-7),分别通过Select和Choos函数两种方法用英文显示对应的星期一-星期日 扫码下载作业帮搜索答疑一搜即得 答案解析 查看更多优质解析 解答一 举报 Alt+F11,然后Alt+IM,在弹出窗口粘帖下面内容:Function chooseTest(myDay As Integer) As StringchooseTest = Choose(myDay,"Monday","Tuesday","Wednes...
int main(){ int a;scanf("%d",&a);if(a==1)printf("Monday\n");else if(a==2)printf("Tuesday\n");else if(a==3)printf("Wensday\n");else if(a==4)printf("Turthday\n");else if(a==5)printf("Friday\n");else if(a==6)printf("Sarthday\n");else if(a==7)pr...
思路:定义一个字符串数组,把星期名分别放到该字符数组的1-7位置,再输入一个整型数n,则直接输出该数组n位置的字符串。参考代码:include<stdio.h>#include<string.h>int main(){char a[8][20]={"","monday","tuesday","wednesday","thursday","friday","saturday","sunday"};int n;scanf...
include"stdio.h" main() { int a; scanf("%d",&a); swith(a) { 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")...这是我的中国科大一朋友写的,...
else if(a==7)printf("Sunday\n");else printf("Illegal day\n");return 0;} C语言程序设计 1、程序运行从main()函数开始,也从main()函数结束。2、函数是C程序的基本单位,由函数头和函数体组成。3、C语言源程序是由函数组成,它们的数目可以有多个。4、在C语言源程序中,是必须有一个函数...