6 条题解
- 1
信息
- ID
- 155
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 2
- 标签
- 递交数
- 219
- 已通过
- 137
- 上传者
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
cin>>a>>b>>c;
cout<<max(a,max(b,c));
return 0;
}
```cpp#include <iostream>
using namespace std;
int main()
{
int a,b,c,naxn;
cin >> a >> b >> c;
if (a>b&&a>c)
naxn= a;
if (b>a&&b>c)
naxn = b;
if (c>a&&c >b)
naxn = c;
cout << naxn;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[5];
cin>>a[1]>>a[2]>>a[3];
sort(a+1,a+4);
cout<<a[3];
return 0;
}
max是什么,我不知道!我只爱sort
在Python中,max()
是一个内置函数,用于返回给定可迭代对象(如列表、元组、字符串等)中的最大值,或者返回给定的一组数值中的最大值。
在c++中sort
是一个函数,用于对数组或容器(如 vector
、list
等)中的元素进行排序。这个函数是 <algorithm>
头文件的一部分,属于标准模板库(STL)。
sort
函数默认按照升序(从小到大)对元素进行排序,但你也可以通过提供一个自定义的比较函数或可调用对象来改变排序的方式。
样例代码
#include<iostream>
using namespace std;
int main(){
int q[3],max=-1;
for(int i=0;i<3;i++)
{
cin>>q[i];
if(q[i]>max) max=q[i];
}
cout<<max;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int q[3],max=-1;
for(int i=0;i<3;i++)
{
cin>>q[i];
if(q[i]>max) max=q[i];
}
cout<<max;
return 0;
}