CodeForces
来源:互联网 发布:线切割如何编程链轮 编辑:程序博客网 时间:2024/05/11 14:39
题目链接:http://codeforces.com/problemset/problem/686/B
题意:给你一串数字,要你把它从小到大排序,并输出每次排序的操作,具体情况题目有具体介绍;
思路:简单的排序题,看代码
#include<iostream>#include<cmath>#include<stdio.h>#include<cstring>#include<algorithm>#include<map>using namespace std;int s[105];int main(){ int n; while(scanf("%d",&n)==1) { for(int i=1;i<=n;i++) scanf("%d",&s[i]); for(int i=1;i<=n;i++) for(int j=1;j<n;j++) { int k=j+1; if(s[j]>s[k]) { int t=s[j]; s[j]=s[k]; s[k]=t; printf("%d %d\n",j,k); } } } return 0;}
之所以会写这篇博客是因为当初题意看错了,WA了一个多小时QAQ;
1 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Linux_C笔记day05
- iOS 安全模型浅析(二) ---- 沙盒机制
- 烤鸡
- HTTP协议GET和POST请求对比
- EXCEL大数据导出(100W条)
- CodeForces
- LeetCode之Remove Duplicates from Sorted Array II
- 一道面试题引发的对 JS 类型转换的思考
- zstu4266-回文
- UML之序列图
- 实验室智能管理系统(2)——Arm+QT部分(二)
- JDBC为什么要使用PreparedStatement而不是Statement
- LeetCode005 Longest Palindromic Substring
- Android应用之广告轮播view, 自动循环轮播