分析题意
输入2个数字,从小到大输出
建立模型
输入两个数字a,b
如果 a>b : //交换a和b
temp=a;
a=b;
b=temp;
输出 a ,b
编写代码
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,temp;
cin>>a>>b;
if(a>b){
temp = a;
a=b;
b=temp;
}
cout<<a<<" "<<b;//输出交换后的a和b
return 0;
}