1110: 零起点学算法17——比较2个数大小

逃离我推掉我的手 2023-01-10 10:14 187阅读 0赞

Description

输入2个整数,按照从大到小输出

Input

2个整数n和m(多组测试数据)

Output

按照从大到小输出,中间用一个空格隔开(每组测试数据一行)

" class="reference-link">Sample Input 5f8f312f51791b8bb0ed0ae07c2ffa43.gif

  1. 14 32
  2. 2 3

Sample Output

  1. 32 14
  2. 3 2

HINT

int is enough

Source

零起点学算法

Code

  1. #include<stdio.h>
  2. #include <math.h>
  3. #include <iomanip>
  4. #include<iostream>
  5. using namespace std;
  6. int main()
  7. {
  8. int n,m;
  9. int t[2];
  10. while(~scanf("%d%d",&n,&m))
  11. {
  12. if(n>m)
  13. {
  14. t[0]=n;
  15. t[1]=m;
  16. }
  17. else
  18. {
  19. t[0]=m;
  20. t[1]=n;
  21. }
  22. cout<<t[0]<<" "<<t[1]<<endl;
  23. }
  24. }

发表评论

表情:
评论列表 (有 0 条评论,187人围观)

还没有评论,来说两句吧...

相关阅读