C++ 十四周任务-冒泡法排序
来源:互联网 发布:淘宝推广时间设置 编辑:程序博客网 时间:2024/06/14 10:20
/* * 程序的版权和版本声明部分 * Copyright (c)2012, 烟台大学计算机学院学生 * All rightsreserved. * 文件名称: array.cpp * 作 者: 王锴英 * 完成日期: 2012年 12月1 日 * 版本号: v1.0 * 输入描述:10个整数 * 问题描述:用冒泡法排序 */ #include<iostream>using namespace std; int bubble_sort(int a[],int s); void output_array(int a[],int s); int main(){ int a[20]={86,76,62,58,77,85,92,80,96,88,77,67,80,68,88,87,64,59,61,76}; int b[15]={27,61,49,88,4,20,28,31,42,62,64,14,88,27,73}; bubble_sort(a,20); output_array(a,20); bubble_sort(b,15); output_array(b,15); return 0; } int bubble_sort(int a[],int s){ int i,j,k; for(i=0;i<s;i++){ for(j=1;j<s-i;j++) if(a[j-1]<a[j]){ k=a[j]; a[j]=a[j-1]; a[j-1]=k; } } return a[s];} void output_array(int a[],int s){ int i; cout<<"ナナミトハラ鬟コ"<<endl; for(i=0;i<s;i++) cout<<a[i]<<" "; cout<<endl; return ; }
运行结果:
- C++ 十四周任务-冒泡法排序
- C++ 十四周任务-冒泡法排序
- 冒泡法数组排序(第十四周上机任务)
- 十四周——排序(冒泡)
- 十四周任务
- 十四周任务二
- 十四周任务一
- 十四周任务2
- 十四周任务2
- 十四周任务1
- 十四周任务二
- 十四周任务2
- 十四周任务2
- 十四周任务一
- 十四周任务2
- 十四周任务一
- 【c++】冒泡法排序
- 十四周作业任务一
- KVM 虚拟机在物理主机之间迁移的实现
- 管理超量使用的 KVM 主机资源
- [Leetcode] Best Time to Buy and Sell Stock II
- android 多媒体框架
- C#中的值传递和引用传递是什么?
- C++ 十四周任务-冒泡法排序
- 必须知道的社会生活中十二大著名法则
- linux下追踪函数调用堆栈
- 利用 libvirt 和 Linux 审计子系统跟踪 KVM 客户机
- Windows Store 平台移植 —— (1) 序言
- 用指针变量指向数组元素。
- delete archivelog all 无法彻底删除归档日志?
- Activity中ConfigChanges属性的用法
- 【css与html】如何让textarea自适应高度?