CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C/C++ >  C语言

简单的问题.这段代码那里出错? 谢谢

楼主webrabbit(猪头)2003-09-01 22:48:49 在 C/C++ / C语言 提问

#include   <iostream>  
  using   namespace   std;  
  int   main()   {  
  int   i;  
  cout<<"type   a   number   and   'enter'"<<endl;  
  cin>>i;  
  if   (i>5)  
  cout<<"it's   greater   than   5"<<endl;  
  else    
  cout<<   "It's   less   than   5"<<endl;  
  else    
  cout<<   "It's   equal   to   5   "<<endl;  
  cout<<   "type   a   number   and   'enter'"<<endl;  
  cin>>i;  
  if(i<10)  
  if(i>5)  
  cout<<   "5<i<10"<<endl;  
  else    
  cout<<   "i<=5"<<endl;  
  else  
  cout<<   "i>=10"<<endl;  
  }  
  问题点数:100、回复次数:5Top

1 楼catface(峰)回复于 2003-09-01 23:00:55 得分 20

IF     连接两个ELSE根本没区别么    
   
  比如MAIN下面这段  
  int   i;  
  cout<<"type   a   number   and   'enter'"<<endl;  
  cin>>i;  
  if   (i>5)  
  cout<<"it's   greater   than   5"<<endl;  
  else    
  cout<<   "It's   less   than   5"<<endl;  
  else    
  cout<<   "It's   equal   to   5   "<<endl;  
  如果I小于5   是     打印     It's   less   than   5     还是打印It's   equal   to   5??Top

2 楼alan118(The Server Side)回复于 2003-09-01 23:01:38 得分 0

vc6下的错误输出说明了一切:illegal   else   without   matching   if  
  if和else没有匹配  
  #include   <iostream>  
  #include   <stdlib.h>  
  using   namespace   std;  
  int   main()   {  
  int   i=0;  
  cout<<"type   a   number   and   'enter'"<<endl;  
  cin>>i;  
  if   (i>5)  
  cout<<"it's   greater   than   5"<<endl;  
  else   if(i<5)  
  cout<<   "It's   less   than   5"<<endl;  
  else    
  cout<<   "It's   equal   to   5   "<<endl;  
  cout<<   "type   a   number   and   'enter'"<<endl;  
  cin>>i;  
  if(i<10)  
  if(i>5)  
  cout<<   "5<i<10"<<endl;  
  else   if(i<=5)  
  cout<<   "i<=5"<<endl;  
  else  
  cout<<   "i>=10"<<endl;  
  system("PAUSE");  
  return   0;  
  }  
  Top

3 楼alan118(The Server Side)回复于 2003-09-01 23:02:10 得分 80

vc6下的错误输出说明了一切:illegal   else   without   matching   if  
  if和else没有匹配  
  #include   <iostream>  
  #include   <stdlib.h>  
  using   namespace   std;  
  int   main()   {  
  int   i=0;  
  cout<<"type   a   number   and   'enter'"<<endl;  
  cin>>i;  
  if   (i>5)  
  cout<<"it's   greater   than   5"<<endl;  
  else   if(i<5)  
  cout<<   "It's   less   than   5"<<endl;  
  else    
  cout<<   "It's   equal   to   5   "<<endl;  
  cout<<   "type   a   number   and   'enter'"<<endl;  
  cin>>i;  
  if(i<10)  
  if(i>5)  
  cout<<   "5<i<10"<<endl;  
  else   if(i<=5)  
  cout<<   "i<=5"<<endl;  
  else  
  cout<<   "i>=10"<<endl;  
  system("PAUSE");  
  return   0;  
  }  
  Top

4 楼webrabbit(猪头)回复于 2003-09-01 23:13:11 得分 0

谢过.Top

5 楼webrabbit(猪头)回复于 2003-09-01 23:15:39 得分 0

system("PAUSE");  
  return   0;  
   
  这二句不加,,也能调试成功,我是初学者,,请问.这二句代码代表了什么意思啊?Top

6 楼catface(峰)回复于 2003-09-02 18:37:02 得分 0

运行后产生     按任意键继续  
  就是暂停屏幕     好看清楚些  
  getchar()     就是等待输入     也是暂停屏幕的土办法  
   
   
  return   0么     因为正规的C++程序中     都是     int   main     返回0     表示正常退出Top

相关问题

  • 代码出错
  • 新手,写一个简单的代码,但编译出错
  • 很简单的代码逻辑,为什么会出错呢?
  • 一段简单的代码怎么就出错了?
  • ListBox的这段简单代码,为什么会出错的?
  • 我这代码那里出错了呢?高分求教~~~
  • 请问这段代码那里出错了?
  • “添加”功能,简单,但是出错!请帮忙看看!代码已附上!
  • 近来看看这段代码,究竟为什么出错了,很简单的
  • 简单的数据库操作,为什么会出错呢?附上代码

关键词

  • cout
  • using namespace std
  • main
  • include

得分解答快速导航

  • 帖主:webrabbit
  • catface
  • alan118

相关链接

  • C/C++ Blog
  • C/C++类图书
  • C/C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo