c语言题目:根据用户输入的时间序号显示相应的问候信息
作者:野牛程序员:2023-12-05 15:26:04c语言阅读 4402
c语言题目:
[题目内容]编程在屏幕上显示一张如下所示的时间表:
*******Time*******
1morning
2afternoon
3night
Please enter your choice: 根据用户输入的时间序号显示相应的问候信息,
选择1时显示“Good morning”,
选择2时显示“Good afternoon”,
选择3时显示“Good night”,
对于其他选择显示“Selection error!”。
[输入]
序号
[输出]
问候语或其他信息
#include <stdio.h>
int main() {
printf("*******Time*******\\n\\n");
printf("1morning\\n");
printf("2afternoon\\n");
printf("3night\\n");
printf("Please enter your choice: ");
int choice;
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Good morning");
break;
case 2:
printf("Good afternoon");
break;
case 3:
printf("Good night");
break;
default:
printf("Selection error!");
}
return 0;
}野牛程序员教少儿编程与信息学奥赛-微信|电话:15892516892

