C语言输入1~12 数字输出月份
时间: 2023-04-05 21:04:42 浏览: 189
可以回答这个问题。以下是C语言代码:
#include <stdio.h>
int main() {
int month;
printf("请输入1~12之间的数字:");
scanf("%d", &month);
switch(month) {
case 1:
printf("一月\n");
break;
case 2:
printf("二月\n");
break;
case 3:
printf("三月\n");
break;
case 4:
printf("四月\n");
break;
case 5:
printf("五月\n");
break;
case 6:
printf("六月\n");
break;
case 7:
printf("七月\n");
break;
case 8:
printf("八月\n");
break;
case 9:
printf("九月\n");
break;
case 10:
printf("十月\n");
break;
case 11:
printf("十一月\n");
break;
case 12:
printf("十二月\n");
break;
default:
printf("输入错误,请输入1~12之间的数字。\n");
break;
}
return 0;
}
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)