编号及代码:
- /*
- *Copyright (c) 2014,烟台大学计算机学院
- *ALL right reserved
- *文件名;test。cpp
- *作者;范星月
- *完成日期2014年10月23日
- *版本号v1.0
- *
- *问题描述:输入二十个整数,输出它们的和
- *输入描述:输入二十个整数
- *程序输出:输出二十个整数的和
- */
</pre><p> </p><pre class="html" name="code">#include <iostream>
using namespace std;
int main()
{
int k,x,max ;
cin >>x;
max =x;
for (k=2;k<=10;k++)
{
cin >>x;
if (max <=x)
max =x;
}
cout << "max =" <<max <<endl;
return 0;
}
运行结果:
学习总结:输出10个数的最大值,先设定第1个数最大,再依次将这个数与另9个数比较,将max赋予最大值
学习心得:熟能生巧,加油!!!