C语言 首字母 判断 星期几
/*请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母。*/#include<stdio.h>intmain(){charc1,c2;p...
/*请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,
则继续 判断第二个字母。*/
#include<stdio.h>
int main()
{
char c1,c2;
printf("please input a letter:\n");
scanf("%c",&c1);
if(c1=='m')
printf("monday\n");
if(c1=='t')
{
printf("please input the second letter:\n");
scanf("%c",&c2);
if(c2=='u')
printf("tuesday\n");
if(c2=='h')
printf("thursday\n");
}
if(c1=='w')
printf("wednesday\n");
if(c1=='f')
printf("friday\n");
if(c1=='s')
{
printf("please input the second letter:\n");
scanf("%c",&c2);
if(c2=='a')
printf("saturday\n");
if(c2=='u')
printf("sunday\n");
}
return 0;
} 展开
则继续 判断第二个字母。*/
#include<stdio.h>
int main()
{
char c1,c2;
printf("please input a letter:\n");
scanf("%c",&c1);
if(c1=='m')
printf("monday\n");
if(c1=='t')
{
printf("please input the second letter:\n");
scanf("%c",&c2);
if(c2=='u')
printf("tuesday\n");
if(c2=='h')
printf("thursday\n");
}
if(c1=='w')
printf("wednesday\n");
if(c1=='f')
printf("friday\n");
if(c1=='s')
{
printf("please input the second letter:\n");
scanf("%c",&c2);
if(c2=='a')
printf("saturday\n");
if(c2=='u')
printf("sunday\n");
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询