Sdut Object-Oriented Programming Practice 6 (class and object)

Source: Internet
Author: User

Sdut Object-Oriented Programming Practice 6 (class and object)

Object-Oriented Programming Practice 6 (class and object) Time Limit: 1000 MS Memory limit: 65536 K This topic describes how to use a class member function to input five integer array elements, sort them from small to large, and output the sorted array elements. Input 5 array elements. Output the results of sorting 5 array elements in ascending order. (There is no space or line feed after the last number) Example Input
8 9 1 5 4
Sample output
1 4 5 8 9
Prompt source zlh sample program

# Include

 
  
Using namespace std; // defines the class type class shuzu {// defines the private part private: int a [5]; // defines the public part public: void input () // input the member function {for (int I = 0; I <5; I ++) cin> a [I];} void pai () // sorting member function {int I, j, p; // sort for (I = 0; I <4; I ++) for (j = 0; j <4-i; j ++) if (a [j]> a [j + 1]) {p = a [j]; a [j] = a [j + 1]; a [j + 1] = p ;}} void output () // output member function {cout <

  

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.