/*
*copyright (c) 2014, College of Computer Science, Yantai University
*all rights reserved.
* File Name: 16 weeks (array sort)
* Wangzhong
* Completion Date: 2014.12.11
* Version Number: v1.0
*
* Problem Description: Sort two array bubbles
* Input Description: None
* Program output: bubble sort after output
#include <iostream>using namespace std;void sort (int *p, int num); Do not change the declaration of a custom function void output (int*, int); The name of the formal parameter can not be int main () //Do not have any changes to the main function {int a[20]={ 86,46,22,18,77,45,32,80,26,88,57,67,20,18,28,17,54,49,11,16};int b[15]={ 27,61,49,88,4,20,28,31,42,62,64,14,88,27,73};sort (a,20); Sort the element output (a,20) in descending order by bubbling method; Output sorted array sort (b,15); Sort the element output (b,15) in descending order by bubbling method; Output sorted array return 0;} void sort (int *p, int num) { int t,i,j; for (j=0;j<num;j++) for (i=0;i<num-j-1;i++) if (* (p+i) >* (p+i+1)) { t=* (p+i); * (p+i) =* (p+i+1); * (p+i+1) =t; }} void output (int*p, int n) {for (int i=0;i<n;i++) cout<<* (p+i) << ""; Cout<<endl;}
16 weeks (Array sort)