| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 817 人关注过本帖, 1 人收藏
标题:感觉两个程序是一样的,前者可以运行而后者不可以,求解释!
取消只看楼主 加入收藏
教皇
Rank: 1
等 级:新手上路
帖 子:71
专家分:0
注 册:2011-10-6
结帖率:95.65%
收藏(1)
已结贴  问题点数: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
快速回复:感觉两个程序是一样的,前者可以运行而后者不可以,求解释!
数据加载中...
 
   



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

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