1110: 零起点学算法17——比较2个数大小
Description
输入2个整数,按照从大到小输出
Input
2个整数n和m(多组测试数据)
Output
按照从大到小输出,中间用一个空格隔开(每组测试数据一行)
" class="reference-link">Sample Input 
14 32
2 3
Sample Output
32 14
3 2
HINT
int is enough
Source
零起点学算法
Code
#include<stdio.h>
#include <math.h>
#include <iomanip>
#include<iostream>
using namespace std;
int main()
{
int n,m;
int t[2];
while(~scanf("%d%d",&n,&m))
{
if(n>m)
{
t[0]=n;
t[1]=m;
}
else
{
t[0]=m;
t[1]=n;
}
cout<<t[0]<<" "<<t[1]<<endl;
}
}
还没有评论,来说两句吧...