C++程序题 对10个整数的最大值

来源:百度知道 编辑:UC知道 时间:2024/05/23 20:00:38
要求:1、输入10个整数
2、求最大值
3、输出10个整数
要精炼的。。。本来就不是很难的题,谁的精炼分数给谁

#include <iostream>
using namespace std;

int main()
{
int a[10];
for(int i=0,i<10,i++)
cin>>a[i];
int max=a[0]
for(int i=1,i<10,i++)
{if(a[i]>max) max=a[i];}
for(int i=0,i<10,i++)
cout<<a[i]<<" ";
cout<<endl;
system("pause");
return 0;
}

#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
int a[10];
for( int i = 0; i < 10; i++ )
{
cin >> a[i];
}
sort(a,a+10);
cout << "最大值: " << a[9] << endl;
cout << "排序: " << endl;
for( int i = 0; i < 10; i++ )
{
cout << a[i] << endl;
}
return 0;
}

气死人,不偿命.简单的要命,您别活了.

写C++,关键是用"类"来写程序,上面两位的回答都没有用到类,这样C和C++就没什么区别了~~<