题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2016

题目大意:给你 n 个数,把最小的数和第一个数字互换,然后输出

解题思路:

很水,开数组,遍历并记录 min ,最后 swap 输出

代码

 #include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
using namespace std;
int num;
int s[];
int main()
{
int n;
int x;
int p;
int min = ;
while(cin >> n && n)
{
// 没必要. memset(s, 0, sizeof(int));
min = ;
for(int i = ; i < n; i ++)
{
cin >> s[i];
if(s[i] < min)
{
min = s[i];
p = i;
}
}
swap(s[], s[p]);
for(int i = ; i < n; i ++)
{
if(i != n - )
cout << s[i] << " " ;
else
cout << s[i] ;
}
//if(n != 0)
cout << endl;
}
}

最新文章

  1. Android中Fragment和ViewPager那点事儿(仿微信APP)
  2. HTML转义字符集合
  3. 在Linux下部署activemq
  4. HDU-4635 Strongly connected 强连通,缩点
  5. Linux下套接字具体解释(三)----几种套接字I/O模型
  6. ZOJ3827 ACM-ICPC 2014 亚洲区域赛的比赛现场牡丹江I称号 Information Entropy 水的问题
  7. PHP时间戳与时间相互转换(精确到毫秒)
  8. cron expr
  9. day4作业小代码练习
  10. Spring MVC处理(下周完善)
  11. FreeNas搭建踩坑指南(二)
  12. Excel表格中依据某一列的值,将这列中一样的数据放在一个文件中。
  13. vue打包上传oss
  14. 关闭2010中 word每次都提示:所做更改会影响共用模板 Normal.dotm
  15. L267 How to save money
  16. mysql学习笔记(三)
  17. iOS 设置textfield的最大文本长度
  18. expect中使用exec执行shell命令
  19. SpringBoot 之HelloController
  20. Python自动化之高级语法单例模式

热门文章

  1. 1. git 本地给远程仓库创建分支 三步法
  2. SpringCloud(五)学习笔记之Hystrix
  3. 在Eclipse上实现简单的JDBC增删查改操作
  4. nginx 配置大吞吐量
  5. Synchronous and Asynchronous I/O [Windows]
  6. JAVA企业级应用TOMCAT实战(三)
  7. Java ASM3学习(3)
  8. RANet : 分辨率自适应网络,效果和性能的best trade-off | CVPR 2020
  9. 怎么查看当前的git分支是基于哪个分支创建的?
  10. c/c++获取文件夹下所有文件名