返回   cpper编程论坛 > Zion/测试
注册账号 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记版面已读

Zion/测试 惹人烦的东西这边来

回复
 
LinkBack 主题工具 显示模式
  #1 (permalink)  
旧 2005-05-30
up2009 的头像
普通会员
 
注册日期: 2005-05-11
帖子: 37
up2009 正向着好的方向发展
默认 初学者问题之四、五

#include <iostream>
#include <iomanip>
#include <stdlib.h>
using namespace std;
int main()
{
int count = 1;
while ( count <= 10) {
cout << ( count % 2 ? "*****": "++++++++" )
<< endl;
++count;
}
return 0;
}
/*
int count=1,number,number1,number2,largest;

cout<<"Enter number (-1 to end): ";
cin>> number1;
cout<<endl;
while (count<=9)
{
cout<<"Enter number (-1 to end): ";
cin>> number2;
cout<<endl;
if(number1>=number2)
number=number1;
else
number=number2;
number1=number;
count++;
}
cout<<"the largest number is:"<<number<<endl;
char quit;
cout<<"quit?";
cin>>quit;
if(quit=='q')
return 0;

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #2 (permalink)  
旧 2005-05-30
up2009 的头像
普通会员
 
注册日期: 2005-05-11
帖子: 37
up2009 正向着好的方向发展
默认

奇观了,编译说第5行“int main() ”错误
unterminated comment
[Build Error] [progame/练习.o] Error 1
我怎也看不明白
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #3 (permalink)  
旧 2005-05-30
up2009 的头像
普通会员
 
注册日期: 2005-05-11
帖子: 37
up2009 正向着好的方向发展
默认

另外,/*后面的程序,现在只能找最大数,不能限制每个数只能输入一次。
题目:寻找10个数中的两个最大数。注意:每个数只允许输入一次
我怎样才能只允许输入一次,不会是让我存入10个变量吧,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #4 (permalink)  
旧 2005-05-30
up2009 的头像
普通会员
 
注册日期: 2005-05-11
帖子: 37
up2009 正向着好的方向发展
默认

引用:
作者: up2009
奇观了,编译说第5行“int main() ”错误
unterminated comment
[Build Error] [progame/练习.o] Error 1
我怎也看不明白
这个问题解决了,不过我更迷惑了。
就是把“/*”后面的统统删掉,程序OK了。
??????
/*后面也有关系吗,迷惑中。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #5 (permalink)  
旧 2005-05-30
up2009 的头像
普通会员
 
注册日期: 2005-05-11
帖子: 37
up2009 正向着好的方向发展
默认

明白了,后面要加“*/”,偷懒了一下,以为效果是一样的。
嘻嘻,麻烦贵眼了。
有时间的话指教一下:
寻找10个数中的两个最大数。注意:每个数只允许输入一次
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #6 (permalink)  
旧 2005-06-01
普通会员
 
注册日期: 2004-08-19
帖子: 87
wwwttt579 正向着好的方向发展
默认

寻找10个数中的两个最大数。注意:每个数只允许输入一次
代码:
A=x[0], B=x[1]; if ( A < B ) A = x[1], B = X[0]; for ( i=2; i<n; i++) { if ( x[i] > A ) B = A, A = x[i]; else if ( x[i] > B ) B = x[i]; }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #7 (permalink)  
旧 2005-06-01
up2009 的头像
普通会员
 
注册日期: 2005-05-11
帖子: 37
up2009 正向着好的方向发展
默认

引用:
作者: wwwttt579
寻找10个数中的两个最大数。注意:每个数只允许输入一次
代码:
A=x[0], B=x[1]; if ( A < B ) A = x[1], B = X[0]; for ( i=2; i<n; i++) { if ( x[i] > A ) B = A, A = x[i]; else if ( x[i] > B ) B = x[i]; }
代码可行,但怎样保证只能输入1次,不行。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #8 (permalink)  
旧 2005-06-02
普通会员
 
注册日期: 2004-08-19
帖子: 87
wwwttt579 正向着好的方向发展
默认

引用:
保证只能输入1次
这是什么意思?
是指这十个数不能有重复么?如此,则必须保存所有的输入数值,才能判断了
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #9 (permalink)  
旧 2005-06-03
up2009 的头像
普通会员
 
注册日期: 2005-05-11
帖子: 37
up2009 正向着好的方向发展
默认

还真是这样啊,谢谢了。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
回复

书签
主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 启用
Pingbacks are 启用
Refbacks are 启用



所有时间均为格林尼治时间 +9。现在的时间是 07:51 AM


Powered by vBulletin® 版本 3.7.0
版权所有 ©2000 - 2009,Jelsoft Enterprises Ltd.
(C) Copy Right All Right Reserved 2001 - 2007

Search Engine Friendly URLs by vBSEO 3.1.0