标题:从输入的第一个字母或第二个来识别星期几
取消只看楼主
小武哥253
Rank: 2
等 级:论坛游民
帖 子:14
专家分:10
注 册:2013-7-27
 问题点数:0 回复次数:0 
从输入的第一个字母或第二个来识别星期几
#include "stdafx.h"
#include "stdio.h"
int main(int argc, char* argv[])
{ //Sunday\Monday\Tuesday\Wednesday\Thursday\Friday\Saturday
char c;
printf("please enter the first number:\n");
while((c=getchar())!='\n')
{
switch(c)
{case 'S':
printf("please enter the second number:\n");
if((c=getchar())=='a')
printf("Saturday.\n");
else if((c=getchar())=='u')
printf("Sunday.\n");
else
printf("error data.\n");break;
case 'M':
printf("Monday.\n");break;
case 'T':
printf("please enter the second number:\n");
if((c=getchar())=='u')
printf("Tuesday.\n");
else if((c=getchar())=='h')
printf("Thursday.\n");
else
printf("error data.\n");break;
case 'W':printf("Wednesday.\n");break;
case 'F':printf("Friday.\n");break;
default:printf("error input.\n");
}
}
return 0;
}
这个程序在进行Saturday和Tuesday选择会出错
搜索更多相关主题的帖子: include please number second 
2013-08-07 06:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-418726-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.213425 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved