2.+在屏幕上显示一张如下所示的时间表: *****Time***** 1+morning 2+afternoon 3+night Please+enter+your+choice: 操作人员根据提示
时间: 2023-11-22 14:46:24 浏览: 32
选择相应的时间序号,程序会显示相应的问候信息。这是一个简单的交互式程序,用户可以通过输入数字来选择不同的时间段,程序会根据用户的选择输出相应的问候语。这个程序可以通过使用switch语句来实现,switch语句会根据用户输入的数字来执行相应的代码块。下面是一个示例代码:
#include <stdio.h>
int main() {
int choice;
printf("*****Time*****\n");
printf("1. morning\n");
printf("2. afternoon\n");
printf("3. night\n");
printf("Please enter your choice: ");
scanf("%d", &choice);
switch(choice) {
case 1:
printf("Good morning!\n");
break;
case 2:
printf("Good afternoon!\n");
break;
case 3:
printf("Good night!\n");
break;
default:
printf("Invalid choice!\n");
break;
}
return 0;
}