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 <