标题:感觉两个程序是一样的,前者可以运行而后者不可以,求解释!
取消只看楼主
教皇
Rank: 1
等 级:新手上路
帖 子:71
专家分:0
注 册:2011-10-6
结帖率:95.65%
已结贴  问题点数:10 回复次数:1 
感觉两个程序是一样的,前者可以运行而后者不可以,求解释!
#include "stdio.h"                              
main()
{
 char i;
 printf("please input the first letter of someday\n");
 while ((i=getchar())!='\n')
 
 {
  switch(i)
 {
  case 'm':printf("1");
  break;
  case 'w':printf("3");  
  break;         
      
  case 'f' :printf("5");
  break;   
  case't': printf("next\n");
      
  if((i=getchar())=='u')
           printf("2");
  else if((i=getchar())=='h')
           printf("4");
  else
           printf("error");
  break;
  case's':  printf("next\n");
     
  if((i=getchar())=='a')
           printf("6");
  else if((i=getchar())=='u')
           printf("7");
  else
           printf("error");
  break;
  default:
           printf("error");
 }
 }
}


#include "stdio.h"
main()
{
char i;
printf("please input the first letter of someday\n");
while((i=getch())!='\n')
{
switch (i)
{
case 's':printf("next\n");
if((i=getch())=='a')
printf("6\n");
else if ((i=getch())=='u')
printf("7\n");
else printf("data error\n");
break;
case 'f':printf("5\n");break;
case 'm':printf("1\n");break;
case 't':printf("next\n");
if((i=getch())=='u')
printf("2\n");
else if ((i=getch())=='h')
printf("4\n");
else printf("data error\n");
break;
case 'w':printf("3\n");break;
default: printf("data error\n");
}
}
}










搜索更多相关主题的帖子: include someday next please letter 
2012-02-01 00:08
教皇
Rank: 1
等 级:新手上路
帖 子:71
专家分:0
注 册:2011-10-6
得分:0 
谢谢
2012-02-01 13:34



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




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

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