A380.最大数输出 题解
2026-07-14 12:46:30
发布于:浙江
6阅读
0回复
0点赞
首先:找出考点
经过读题可知,此题目可以使用if/else语句,max() 函数,sort() 排序函数,冒泡排序,桶排序……方法完成。
步骤:
- 源代码写好(确保没有写错,建议使用万能头文件)
if/else语句 使用变量或数组,分别判断max()函数 使用变量或数组,直接求出最大数sort()排序函数 使用数组,直接排序,后输出最大值
检查:
- 是否
return 0; - 是否每句后写上
; - 代码是否打错
最后
if/else语句题解
#include<bits/stdc++.h>
using namespace std;
int main() {
int A,B,C;
cin>>A>>B>>C;
if(A>B){
if(A>C){
cout<<A<<endl;
} else{
cout<<C<<endl;
}
}
else{
if(B>C){
cout<<B<<endl;
} else{
cout<<C<<endl;
}
}
return 0;
}
max() 函数题解
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
cout<<max(a,max(b,c));
return 0;
}
sort() 排序函数题解
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[10];
for(int i=1;i<=3;i++){
cin>>a[i];
}
sort(a+1,a+1+3);
cout<<a[3]<<endl;
return 0;
}
全部评论 1
- 置顶
@༺ཌༀ我要上南开ༀད༻@码农爱历史@鉴湖小学 王泽睿 六年级@Wemmbu@沈择园:小号@白菜对我笑拿题解仙人qwq help me please
8小时前 来自 浙江
2d
8小时前 来自 湖北
1QWQ
8小时前 来自 浙江
1








有帮助,赞一个