Week 4 Project 5: array as a data member

Source: Internet
Author: User
/** Program Copyright and version description Section * copyright (c) 2012, Yantai University Computer college student * All rightsreserved. * file name: object. CPP * Author: Li Yang * Completion Date: July 15, March 23, 2013 * version: V1.0 * input Description: none * Problem description: none * program output: none */# include <iostream> using namespace STD; class salary {public: void set_salary (); void add_salary (int x); void sort_salary (); void show_salary (); Private: Double salary [50]; int number ;}; void salary: set_salary () {int X, I = 0; cout <"Enter the salary:" <Endl; CIN> X; while (x> 0) {salary [I] = x; ++ I; CIN> X;} number = I;} void salary: add_salary (int x) {int I; for (I = 0; I <number; ++ I) Salary [I] + = x;} void salary: sort_salary () {int I, j; Double T; for (j = 0; j <number-1; j ++) for (I = 0; I <number-j-1; I ++) if (salary [I] <salary [I + 1]) {T = salary [I]; salary [I] = salary [I + 1]; salary [I + 1] = T ;}} void salary: show_salary () {int I; for (I = 0; I <number; ++ I) cout <salary [I] <"" ;}int main () {salary s; S. set_salary (); S. add_salary (100); S. sort_salary (); S. show_salary (); cout <Endl; return 0 ;}

Related Article

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.