Aizu ALDS1_2_A Bubble Sort(冒泡排序)
来源:互联网 发布:腾讯微云网盘for mac 编辑:程序博客网 时间:2024/05/01 21:17
#include <bits/stdc++.h>#define _ ios_base::sync_with_stdio(0);cin.tie(0);#define INF 0x3f3f3f3f#define eps 1e-5typedef long long LL;const double pi = acos(-1.0);const long long mod = 25 * 1E8;using namespace std;int a[200005];int main(){ //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); ios_base::sync_with_stdio(0);cin.tie(0); int n; cin >> n; int ans = 0; for(int i = 0;i < n;i++) cin >> a[i]; for(int i = 0;i < n;i++) for(int j = n - 1;j >= i + 1;j--) if(a[j] < a[j - 1]) swap(a[j],a[j - 1]),ans++; for(int k = 0;k < n - 1;k++) printf("%d ",a[k]); printf("%d\n",a[n - 1]); printf("%d\n",ans); return 0;}
0 0
- Aizu ALDS1_2_A Bubble Sort(冒泡排序)
- 第三章 ALDS1_2_A:Bubble Sort 冒泡排序法
- ALDS1_2_A:Bubble Sort
- 冒泡排序(Bubble Sort)
- 冒泡排序(bubble sort)
- 冒泡排序(Bubble Sort)
- 冒泡排序 (Bubble sort)
- 冒泡排序(bubble sort)
- Bubble Sort(冒泡排序)
- 冒泡排序(Bubble sort)
- 冒泡排序(Bubble Sort)
- 冒泡排序(Bubble Sort)
- 冒泡排序(Bubble Sort)
- 冒泡排序(Bubble Sort)
- Bubble-Sort(冒泡排序)
- 冒泡排序(bubble sort)
- 冒泡排序(Bubble Sort)
- Bubble Sort(冒泡排序)
- Golang 目录文件数量和大小统计
- AlphaGo
- 学习android开发从现在开始
- C++实现黄金分割法搜索
- Unity UI优化技术与技巧
- Aizu ALDS1_2_A Bubble Sort(冒泡排序)
- 文章标题
- 山东理工大学acm非专业程序设计基础答案
- 关于A a = new B()
- 34-2-lesson exercises
- Unity 使用代码修改Texture属性 一键生成精灵
- 如何关闭Xcode8的系统日志打印
- 中医.辨证论治
- java 使用Thumbnailator 上传图片 并压缩图片大小