输入第一个字母判断星期几,如不可,则判断第二个字母用c语言
时间: 2023-10-21 22:01:06 浏览: 54
实现:
```c
#include <stdio.h>
int main() {
char c;
printf("请输入第一个字母:");
scanf("%c", &c);
if (c == 'M') {
printf("星期一\n");
} else if (c == 'W') {
printf("星期三\n");
} else if (c == 'F') {
printf("星期五\n");
} else if (c == 'T') {
printf("请输入第二个字母:");
scanf(" %c", &c);
if (c == 'u') {
printf("星期二\n");
} else if (c == 'h') {
printf("星期四\n");
} else {
printf("输入有误\n");
}
} else if (c == 'S') {
printf("请输入第二个字母:");
scanf(" %c", &c);
if (c == 'a') {
printf("星期六\n");
} else if (c == 'u') {
printf("星期天\n");
} else {
printf("输入有误\n");
}
} else {
printf("输入有误\n");
}
return 0;
}
```
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![](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)