C语言编程|C语言编程 C Language Programming - 0012
编程题0012 (from Programming Teaching Assistant (PTA))
冒泡排序
输入n
(1<=n<=10
)个整数,将它们从小到大排序后输出,要求编写函数bubble()
实现冒泡排序算法。
【C语言编程|C语言编程 C Language Programming - 0012】函数接口定义:void bubble (int a[ ], int n);
其中, a
为数组,n
为数据个数。
裁判测试程序样例:
#include
void bubble (int a[ ], int n);
int main(void)
{
int n, a[10];
int i;
scanf("%d", &n);
for (i=0;
i
输入样例:
8
7 3 66 3 -5 22 -77 2
输出样例:
-77 -5 2 3 3 7 22 66
Answer:
void bubble (int a[ ], int n){int tmp = 0;
for(int i=0;
ii;
j--){
if(a[j]
推荐阅读
- Book|Book Review: Foundations of Statistical Natural Language Processing
- 关于C语言编程入门基础学习的一些,常识类的小知识,干货分享
- Stream|Stream Programming Guide阅读笔记
- java|ObjectOrientedProgramming - 面向对象的编程(多态、抽象类、接口)- Java - 细节狂魔
- 城镇的语言
- [Programming|[Programming Tracking]Compliers Programming Assignment 1: Lexer
- C语言编程基础学习——链表详解!
- 初生菜鸟|2019The 44th International Collegiate Programming Contest Asia Shenyang Regional Contest
- View|View Programming Guide 笔记
- C语言编程学习二维数组的定义与初始化