1154. Easy sort
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n];
for(int i =0 ;i<n;i++){
int c;
cin>>c;
a[i] = c;
}
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
int tem;
if(a[i]>a[j]){
tem = a[j];
a[j]=a[i];
a[i]=tem;
}
}
}
for(int i =0 ;i<n;i++){
cout<<a[i]<<endl;
}
}
return 0;
}
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n];
for(int i =0 ;i<n;i++){
int c;
cin>>c;
a[i] = c;
}
sort( a,a+n, less<int>() );
for(int i=0;i<n;i++){
cout<<a[i]<<endl;
}
}
return 0;
}
1154. Easy sort的更多相关文章
- sicily 1154. Easy sort (tree sort& merge sort)
Description You know sorting is very important. And this easy problem is: Given you an array with N ...
- [SOJ]Easy sort (归并排序)
Description You know sorting is very important. And this easy problem is: Given you an array with N ...
- Sort Methods
heyheyhey ~~ It has been a long time since i come here again...whatever today i will summerize some ...
- uva--11991 - Easy Problem from Rujia Liu?(sort+二分 map+vector vector)
11991 - Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for e ...
- Codeforces Round #650 (Div. 3) F1. Flying Sort (Easy Version) (离散化,贪心)
题意:有一组数,每次操作可以将某个数移到头部或者尾部,问最少操作多少次使得这组数非递减. 题解:先离散化将每个数映射为排序后所对应的位置,然后贪心,求最长连续子序列的长度,那么最少的操作次数一定为\( ...
- [leetcode] 905. Sort Array By Parity [easy]
原题链接 很水的一道题,就是数组内部交换. 水题就想着减少复杂度嘛,于是学到一种交换写法. class Solution { public: vector<int> sortArrayBy ...
- 九度 题目1154:Jungle Roads
题目描写叙述: The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid mon ...
- Sort with Swap(0, i)
原题连接:https://pta.patest.cn/pta/test/16/exam/4/question/678 题目如下: Given any permutation of the number ...
- PAT 1067. Sort with Swap(0,*)
1067. Sort with Swap(0,*) (25) Given any permutation of the numbers {0, 1, 2,..., N-1}, it is easy ...
随机推荐
- Jmeter使用入门
修改时间 修改内容 修改人 2016.3.12 创建 刘永志 2016.6.18 完成 刘永志 Jmeter简介 Jmeter的基本概念 百度百科: Apache JMeter是Apache组织开发的 ...
- Ogre 1.9 Android移植
Ogre 1.9 Android移植 分类: 图形渲染2013-02-04 16:47 3860人阅读 评论(14) 收藏 举报 Android Ogre C++linuxLinuxLINUX 上一篇 ...
- 使用Docker Image跑Gitlab
下载gitlab docker镜像 docker pull gitlab/gitlab-ce:latest 启动gitlab服务 sudo docker run --detach \ --hostna ...
- 实现浏览器打开图片的url默认是下载
在返回的response里面设置HTTP头的Content-Disposition=attachement;filename=xxxx,即可实现文件另存为"xxxx":Conten ...
- 关于js中的for(var in)遍历属性报错问题
之前遇到过这个问题,但是没找到问题的所在,将for(var i in array){} 改成了for(var i ;i<array.length;i++)循环,但是今天又遇到了,mark一下错 ...
- asp.net LINQ防止SQL注入式攻击
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- 【项目】搜索广告CTR预估(二)
项目介绍 给定查询和用户信息后预测广告点击率 搜索广告是近年来互联网的主流营收来源之一.在搜索广告背后,一个关键技术就是点击率预测-----pCTR(predict the click-through ...
- 关于有偿提供拼图响应式后台的通知---------pintuer ui的官方通知(www.pintuer.com)
拼图响应式前端框架版响应式后台正式发布. 考虑到目前拼图的状况,我们不打算免费开放下载,但也不会收各位朋友1分钱,该版后台将有偿提供给各位给予拼图贡献的朋友. 废话不多说,一切皆以有图有真相,下面上图 ...
- python时间函数学习
格式化当前日期: import time print time.strftime('%Y-%m-%d') 获取一天前的日期: import datetime import time onedayago ...
- modelsim搭建uvm环境及实例
Modelsim SE-64 10.2c 自带编译好的uvm-1.1d 脚本new_run.do set UVM_DPI_HOME C:/modeltech64_10.2c/uvm-1.1d/win6 ...