給与ソート
1550 ワード
/*01
02.* :
03.* Copyright (c) 2011,
04.* All rights reserved.
05.* :test.cpp
06.* :
07.* :2014 6 1
08.* :v1.0
09.* :
10.* :
11.* :
12.* :
13.* :
14.* :
*/
#include<iostream>
using namespace std;
class Salary
{
public:
void set_salarys( );
void add_salarys(double x);
void sort_salarys();
void show_salarys( );
private:
double a[50]; //
int number; //
};
int main()
{
cout<<" "<<endl;\
cout<<" -1 , !!!"<<endl;
Salary people;
people.set_salarys();
people.add_salarys(500);
people.sort_salarys();
cout<<" 500 :"<<endl;
people.show_salarys();
return 0;
}
void Salary::set_salarys( )
{
int i=0;
while(1)
{
for(;i<50;)
{ cin>>a[i];
if(a[i]==-1)
{
break;
}
i++;
}
break;
}
number=i;
}
void Salary::add_salarys(double x)
{
for(int i=0;i<number;i++)
{
a[i]+=x;
}
}
void Salary::sort_salarys()
{
int i,j,t;
for(i=0;i<number-1;i++)
for(j=0;j<number-1-i;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
void Salary::show_salarys( )
{
for(int i=0;i<number;i++)
cout<<a[i]<<" ";
}