编写一个程序输出以下菜单: ************ *********** A:Very Good! B:Wonderful! C:Good! D:Pass! ***************: 根据输入的A~D中的任一个字符,输出相应的菜单项
时间: 2023-07-18 16:46:12 浏览: 68
好的,以下是使用 Python 语言编写的程序,请参考:
```python
print("************\t***********")
print("A:Very Good!")
print("B:Wonderful!")
print("C:Good!")
print("D:Pass!")
print("***************")
choice = input("请输入 A~D 中的任一个字符:")
if choice == "A":
print("您选择了 Very Good!")
elif choice == "B":
print("您选择了 Wonderful!")
elif choice == "C":
print("您选择了 Good!")
elif choice == "D":
print("您选择了 Pass!")
else:
print("输入有误,请重新输入 A~D 中的任一个字符!")
```
您可以将以上代码保存为一个 Python 文件,然后在命令行或者 Python 环境中运行,就可以输出菜单并根据用户输入输出相应的内容。
相关问题
c++ 编写程序,显示如下菜单*** ***
以下是一个简单的C程序,可以显示一个菜单:
```c
#include <stdio.h>
int main() {
printf("*** Welcome to the Menu ***\n");
printf("1. Option 1\n");
printf("2. Option 2\n");
printf("3. Option 3\n");
printf("4. Option 4\n");
printf("5. Exit\n");
return 0;
}
```
在这个程序中,我们使用了`printf()`函数来输出菜单的各个选项。`\n`表示换行符。`return 0;`表示程序正常结束。
用c语言编写一个程序输出以下菜单: ************ *********** A:Very Good! B:Wonderful! C:Good! D:Pass! ***************: 根据输入的A~D中的任一个字符,输出相应的菜单项
好的,以下是使用 C 语言编写的程序,请参考:
```c
#include <stdio.h>
int main() {
printf("************\t***********\n");
printf("A:Very Good!\n");
printf("B:Wonderful!\n");
printf("C:Good!\n");
printf("D:Pass!\n");
printf("***************\n");
char choice;
printf("请输入 A~D 中的任一个字符:");
scanf("%c", &choice);
switch (choice) {
case 'A':
printf("您选择了 Very Good!\n");
break;
case 'B':
printf("您选择了 Wonderful!\n");
break;
case 'C':
printf("您选择了 Good!\n");
break;
case 'D':
printf("您选择了 Pass!\n");
break;
default:
printf("输入有误,请重新输入 A~D 中的任一个字符!\n");
break;
}
return 0;
}
```
您可以将以上代码保存为一个 C 文件,然后使用 C 编译器编译并运行,就可以输出菜单并根据用户输入输出相应的内容。
相关推荐
![c](https://img-home.csdnimg.cn/images/20210720083646.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)