51_nod 1018 排序
2017-04-24 11:10
260 查看
1018 排序
基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 取消关注
给出N个整数,对着N个整数进行排序
Input
第1行:整数的数量N(1 <= N <= 50000)
第2 - N + 1行:待排序的整数(-10^9 <= A[i] <= 10^9)
Output
共n行,按照递增序输出排序好的数据。
Input示例
5
5
4
3
2
1
Output示例
1
2
3
4
5
代码:
基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 取消关注
给出N个整数,对着N个整数进行排序
Input
第1行:整数的数量N(1 <= N <= 50000)
第2 - N + 1行:待排序的整数(-10^9 <= A[i] <= 10^9)
Output
共n行,按照递增序输出排序好的数据。
Input示例
5
5
4
3
2
1
Output示例
1
2
3
4
5
代码:
#include<cstdio> #include<iostream> #include<algorithm> #include<cstdlib> long long a[50005]; int n; //bool cmp(long long a,long long b) //{ // return a<b; //升序排列,如果改为return a>b,则为降序 // //}; using namespace std; void bsort(){ for(int i=0;i<=n-2;i++) for(int j=i+1;j<=n-1;j++){ if(a[i]>a[j]){ long long temp; temp=a[i]; a[i]=a[j]; a[j]=temp; } } } int main(){ cin>>n; for(int i=0;i<n;i++){ scanf("%I64d",&a[i]); } //sort(a,a+n); bsort(); for(int i=0;i<n;i++){ printf("%I64d\n",a[i]); } return 0; }
相关文章推荐
- 51 nod 1097 拼成最小的数 思路:字符串排序
- 任务执行排序(51nod 1099)
- 51 nod 1065 最小正子段和 排序大法好
- [51Nod](1095)Anigram单词 ---- Hash(map)+排序
- 51 nod 1241 特殊的排序(思维)@
- 51 nod 1009 数字1的数量
- 51 nod 1273 旅行计划(树DP)
- 51 Nod 1006 最长公共子序列Lcs
- 【置换群】51Nod 1125交换机器的最小代价
- 51 nod 1717 好数
- 51 nod 1174
- 51 Nod 1265 四点共面 (计算几何)
- 51 nod 1310 Chandrima and XOR(规律)
- 51 nod 1385 凑数字(贪心+构造)
- 【51 nod 1189】【素数+整数唯一分解定理】阶乘分数
- 51nod1081---子段求和(51nod基础:前缀和)
- 51 nod 1003:一个数阶乘后0的个数
- 51 nod 1140
- 数数字(51nod 1770)
- 51-Nod 1995 三子棋