C语言 编写程序,当输入数月份时,显示相应英文月份名称。
2个回答
展开全部
#include<stdio.h>
int main(void){
char *month[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
int i;
printf("**************输入0结束循环************\n");
while(1){
printf("请输入月份号:");
scanf("%d",&i);
if(i==0){
return 0;
}
printf("该月的英文名为:%s\n",month[i-1]);
}
}
展开全部
#include<stdio.h>
void main()
{
int n;
printf("请输入数字:");
scanf("%d",&n);
switch(n)
{
case 1:printf("Jan \n");break;
case 2:printf("Feb \n");break;
case 3:printf("Mar \n");break;
case 4:printf("Apr \n");break;
case 5:printf("May \n");break;
case 6:printf("Jun \n");break;
case 7:printf("Jul \n");break;
case 8:printf("Agu \n");break;
case 9:printf("Sep \n");break;
case 10:printf("Oct \n");break;
case 11:printf("Nov \n");break;
case 12:printf("Dec \n");break;
}
}
void main()
{
int n;
printf("请输入数字:");
scanf("%d",&n);
switch(n)
{
case 1:printf("Jan \n");break;
case 2:printf("Feb \n");break;
case 3:printf("Mar \n");break;
case 4:printf("Apr \n");break;
case 5:printf("May \n");break;
case 6:printf("Jun \n");break;
case 7:printf("Jul \n");break;
case 8:printf("Agu \n");break;
case 9:printf("Sep \n");break;
case 10:printf("Oct \n");break;
case 11:printf("Nov \n");break;
case 12:printf("Dec \n");break;
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询