c语言求编程!!
发布网友
发布时间:2022-04-23 20:28
我来回答
共3个回答
热心网友
时间:2023-08-13 11:27
#include <stdlib.h>
int main()
{
int i;
printf("####Student List####");
printf("1. John\n");
printf("2. Merry\n");
printf("3. Mike\n");
printf("4. Lisa\n");
printf("5. Tom\n");
printf("Please choose your name:\n");
scanf("%d", &i);
switch (i) {
case 1:
printf("Hello!John");
break;
case 2:
printf("Hello!Merry");
break;
case 3:
printf("Hello!Mike");
break;
case 4:
printf("Hello!Lisa");
break;
case 5:
printf("Hello!Tom");
break;
default:
printf("Wrong choice!");
break;
}
return 0;
}
追问能给出设计思路吗,O(∩_∩)O谢谢
热心网友
时间:2023-08-13 11:27
#include<iostream>
void main()
{
int num;
while(1)
{
printf("Please choose your name:");
scanf("%d",&num);
switch(num)
{
case 1:
printf("Hello!John.\n");
break;
case 2:
printf("Hello!Merry.\n");
break;
case 3:
printf("Hello!Mike.\n");
break;
case 4:
printf("Hello!Lisa.\n");
break;
case 5:
printf("Hello!Tom.\n");
break;
default:
printf("Wrong choice!\n");
break;
}
}
}
热心网友
时间:2023-08-13 11:28
void main()
{
unsigned char NUM;
printf("Please choose your name:\n");
scanf("%d",&NUM);
printf("####Student List####\n");
switch(NUM)
{
case 1:printf("Hello!John");break;
case 2:printf(" Hello! merry");break;
case 3:printf(" Hello! mike");break;
case 4:printf(" Hello! lisa");break;
case 5:printf(" Hello! tom");break;
default: printf("Wrong choice!");break;
}
}