- 论坛徽章:
- 0
|
//Exercise 2.20.cpp
//Find the largest number
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int largest = 0,
larger = 0,
number,
v = 0, //note the number inputted
counter = 10;
while (counter >= 1){
cout << "Input a number :";
cin >> number;
if (number > largest) {
largest = number;
larger = largest;
}
else if (number > larger){
larger = number;
}
--counter;
++v;
cout << "You have inputted " << v << " number " << endl;
}
cout << "\nThe largest number is :" << largest
<<"\nThe larger number is :"<< larger << endl;
system ("pause");
return 0;
}
我输入的是22,45,88,55,66,77,122,3455,55,66,结果是3455,用DEV-C++编译的
[ 本帖最后由 bayernrimnm 于 2008-4-30 17:28 编辑 ] |
|