uva-299
来源:互联网 发布:sass for mac 安装 编辑:程序博客网 时间:2024/06/07 07:45
就是冒泡排序,然后记录一下一共交换了多少次
原题:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=4&problem=235&mosmsg=Submission+received+with+ID+11692850
#include <stdio.h>int n;int l;int trains[60];int bubbleSort(){int i,j,count,temp,swp;count=0;for(i=0;i<l-1;i++){swp=0;for(j=l-1;j>i;j--){if(trains[j]<trains[j-1]){temp=trains[j];trains[j]=trains[j-1];trains[j-1]=temp;count++;swp=1;}}if(0==swp)return count;}return count;}int main(){int i;scanf("%d",&n);while(n--){scanf("%d",&l);for(i=0;i<l;i++)scanf("%d",&trains[i]);printf("Optimal train swapping takes %d swaps.\n",bubbleSort());}return 0;}
- uva--299
- uva-299
- uva 299
- uva 299
- uva-299
- uva 299
- Uva 299
- UVA 299
- UVa 299 Train Swapping
- Uva 299 Train Swapping
- uva 299 Train Swapping
- UVA 299 - Train Swapping
- UVA 299-Train Swapping
- UVa 299 - Train Swapping
- uva-299 - Train Swapping
- UVA 299 列车交换
- UVa 299 - Train Swapping
- UVa 299 - Train Swapping
- Android NDK
- 18、glClearDepthf与glDepthFunc(2012-08-07 )
- 新浪微博开发二------------------------登陆篇
- UVa 112 - Tree Summing
- 类初始化时机
- uva-299
- 任意遥控器遥控C1测试成功,理论上可使用任意遥控
- 【leetcode】Construct Binary Tree from Inorder and Postorder Traversal
- Twitter常用术语和名词解析
- Window下使用Gvim搭建简单IDE
- Server.MapPath详解
- 在 /etc/sysconfig/network-scripts/下没有ifcfg-eth0这个配置文件
- 高效算法设计专项:UVa 10535
- Android4.0之前HttpClient的问题The target server failed to respond