本帖最后由 可爱的医师小小 于 19-10-2011 05:53 PM 编辑
你是什麼語言??還有你可以用一個variable 控制你的while loop 然後裡面就 input 你的數字啊。你post 你的 ...
invisible 发表于 19-10-2011 04:42 PM  注意你的 Operator,= 和 == 有分别的,也是 infinite loop 的主要元凶之一。
geekman 发表于 19-10-2011 05:30 PM 
我把我的coding放上来你们不要笑呀
才学没有几天罢了……
以下是我的题目。
1.Display an appropriate messageheader, e.g. “Start of Task B” 2.Write a whileloop that will iterate exactly 10 times. 3.In each iteration of the loop,prompt the user to enter an integer. 4.Within the body of the loop,sum up the total of these 10 integers. 5.Calculate the average of these10 integers. 6.After the loop, display anappropriate message which shows the total and the average of these 10 integers.
我暂时能够进行到这样而已,至于while loop我也还不是很懂,如果我要连续loop十次,condition是不是放(a>0),但是要怎样break他?
多多赐教!
- #include<iostream>
- using namespace std;
- int main()
- {
- int a;
- cout<< "Start Task B\n";
- cout<<"Please input 10 integer\n";
- cin>>a;
- while (a>0){
- cout<<"Input another number";}
-
- return 0;
- }
复制代码 |