C语言编程输入数字1到7 分别输出周一到周日的英文单词

要求用尽量简单的语法 ,行数稍微多点,标清说明 谢谢达人
2024-11-26 04:21:52
推荐回答(4个)
回答1:

//这个就不用注释了吧
#include "stdio.h"
void main()
{
int i;
printf("输入1~7其中一个数字:");
scanf("%d",&i);
switch(i)
{
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("April Fools' Day\n");break;
}
}

回答2:

#includeint main(void)
{
int week;
do{
scanf("%d",&week);
if(week == 1)
{
printf("Monday\n");
}
else if(week ==2)
{
printf("Tuesday\n");
}
else if(week == 3)
{
printf("Wednesday\n");
}
else if(week == 4)
{
printf("Thursday\n");
}
else if(week == 5)
{
printf("Friday\n");
}
else if(week == 6)
{
printf("Saturday\n");
}
else if(week == 7)
{
printf("Sunday\n");
}
}while (week>0 && week<8);
}

回答3:

#include "stdio.h" void main(){ intnDay; charcDay[7][10] ={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"}; scanf("%d",&nDay); printf("%s\n",cDay[nDay-1]);}

回答4:

输个小数直接GG