数据的交换输出

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 145410    Accepted Submission(s): 53585

Problem Description
输入n(n<100)个数,找出其中最小的数,将它与最前面的数交换后输出这些数。
 
Input
输入数据有多组,每组占一行,每行的开始是一个整数n,表示这个测试实例的数值的个数,跟着就是n个整数。n=0表示输入的结束,不做处理。
 
Output
对于每组输入数据,输出交换后的数列,每组输出占一行。
 
Sample Input
4 2 1 3 4
5 5 4 3 2 1
0
 
Sample Output
1 2 3 4
1 4 3 2 5
 
 
冒泡排序就是啦~!
 #include<iostream>
#include<algorithm>
using namespace std; int main()
{
int a[],n,i;
while(cin>>n&&n!=)
{
int mintemp=,minvalue;
for(i=;i<n;i++)
{
cin>>a[i];
if(i==)minvalue=a[i];
if(a[i]<minvalue)
{
minvalue=a[i];
mintemp=i;
}
}
i=a[mintemp];
a[mintemp]=a[];
a[]=i;
cout<<a[];
for(i=;i<n;i++)
{
cout<<" "<<a[i];
}
cout<<endl;
}
}

杭电ACM2016--数据的交换输出的更多相关文章

  1. HDOJ2016数据的交换输出

    数据的交换输出 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  2. hdu2016 数据的交换输出【C++】

    数据的交换输出 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  3. HDOJ 2016 数据的交换输出

    Problem Description 输入n(n<100)个数,找出其中最小的数,将它与最前面的数交换后输出这些数. Input 输入数据有多组,每组占一行,每行的开始是一个整数n,表示这个测 ...

  4. HDU_2016——数据的交换输出

    Problem Description 输入n(n<100)个数,找出其中最小的数,将它与最前面的数交换后输出这些数.   Input 输入数据有多组,每组占一行,每行的开始是一个整数n,表示这 ...

  5. PAT 2016 数据的交换输出

    http://acm.hdu.edu.cn/showproblem.php?pid=2016 Problem Description 输入n(n<100)个数,找出其中最小的数,将它与最前面的数 ...

  6. hdu 2016 数据的交换输出

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2016 题目大意:把最小的和第一个交换并输出.注意格式哦! #include <stdio.h&g ...

  7. 杭电OJ第11页2010-2019道题(C语言)

    2010. 水仙花数 问题描述 Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: "水仙花数"是指一个三位 ...

  8. 杭电oj2012-2021

    2012  素数判定 #include <stdio.h> #include <math.h> int main() { int x,y,i,j,a,flag; while(s ...

  9. 用python爬取杭电oj的数据

    暑假集训主要是在杭电oj上面刷题,白天与算法作斗争,晚上望干点自己喜欢的事情! 首先,确定要爬取哪些数据: 如上图所示,题目ID,名称,accepted,submissions,都很有用. 查看源代码 ...

随机推荐

  1. Cheat Engine 6.8 设置中文

    下载翻译文件包 https://cheatengine.org/downloads.php 下载后解压到 "Cheat Engine 6.8.3\languages" 下面 修改 ...

  2. sql_update

    学习: http://www.runoob.com/mysql/mysql-tutorial.html replace: update table_name set column = replace ...

  3. IIS中 flv、swf 文件无法播放

    解决方案: 1.服务器安装flash,这是必须的. 2.MIME类型添加两个:名称.swf,值application/x-shockwave-flash:名称.flv,值flv-application ...

  4. HBuilder git使用-建立仓库,邀请用户

    1.git环境配置好后,在Github上注册好帐号 2. 创建一个Respository(代码仓库) 3.邀请其他小组用户(必须的,要不别人提交不了修改) 4.把邀请链接要COPY给其他用户 5. 其 ...

  5. libguestfs手册(1): 架构

    要编辑一个image,则运行下面的命令 guestfish -a ubuntutest.img ><fs> 会弹出一个命令行工具 运行run ><fs> run 我 ...

  6. 【RL-TCPnet网络教程】第4章 RL-TCPnet网络协议栈简介

    第4章        RL-TCPnet网络协议栈简介 本章节介绍RL-TCPnet网络协议栈,让大家对 RL-TCPnet有一个整体的了解,RL-TCPnet是一款小型网络协议栈,适用于 ARM 内 ...

  7. [Java]LeetCode284. 顶端迭代器 | Peeking Iterator

    Given an Iterator class interface with methods: next() and hasNext(), design and implement a Peeking ...

  8. [Swift]LeetCode331. 验证二叉树的前序序列化 | Verify Preorder Serialization of a Binary Tree

    One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, ...

  9. [Swift]LeetCode552. 学生出勤记录 II | Student Attendance Record II

    Given a positive integer n, return the number of all possible attendance records with length n, whic ...

  10. Spring Boot: Yaml配置文件 以及 @ConfigurationProperties属性获取

    Yaml配置文件 概述 Spring Boot在支持application.properties配置文件的同时,也支持application.yaml配置文件. 配置文件中的属性,可以通过: 通过@V ...