16 weeks (Array sort)

Source: Internet
Author: User
Tags array sort



/*
*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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.