#include<iostream>
using namespace std;
class Salary
{
public:
void input_salary();
void add_salary();
void sort_salary();
private:
double salary[50];
int number;
};
int main()
{
Salary ss;
ss.input_salary();
cout<<endl;
cout<<"加100元后的工资为:";
cout<<endl;
ss.add_salary();
cout<<endl;
cout<<"排序后工资为:";
cout<<endl;
ss.sort_salary();
cout<<endl;
system("PAUSE");
return 0;
}
void Salary::input_salary()
{
double x;
int i=0;
cout<<"请输入员工的工资: (输入‘-1’标志着工资输入结束)"<<endl;
cin>>x;
while(x>0)
{
salary[i]=x;
++i;
cin>>x;
}
number=i;
}
void Salary::add_salary()
{
int i;
for (i=0;i<number;i++)
{
salary[i]=salary[i]+100;
cout<<salary[i]<<" ";
}
}
void Salary::sort_salary()
{
int i,j;
double t;
for(i=0;i<number-1;i++)
for(j=0;j<number-i-1;j++)
if(salary[j]>salary[j+1])
{
t=salary[j];
salary[j]=salary[j+1];
salary[j+1]=t;
}
for (i=0;i<number;i++)
{
cout<<salary[i]<<" ";
}
}
using namespace std;
class Salary
{
public:
void input_salary();
void add_salary();
void sort_salary();
private:
double salary[50];
int number;
};
int main()
{
Salary ss;
ss.input_salary();
cout<<endl;
cout<<"加100元后的工资为:";
cout<<endl;
ss.add_salary();
cout<<endl;
cout<<"排序后工资为:";
cout<<endl;
ss.sort_salary();
cout<<endl;
system("PAUSE");
return 0;
}
void Salary::input_salary()
{
double x;
int i=0;
cout<<"请输入员工的工资: (输入‘-1’标志着工资输入结束)"<<endl;
cin>>x;
while(x>0)
{
salary[i]=x;
++i;
cin>>x;
}
number=i;
}
void Salary::add_salary()
{
int i;
for (i=0;i<number;i++)
{
salary[i]=salary[i]+100;
cout<<salary[i]<<" ";
}
}
void Salary::sort_salary()
{
int i,j;
double t;
for(i=0;i<number-1;i++)
for(j=0;j<number-i-1;j++)
if(salary[j]>salary[j+1])
{
t=salary[j];
salary[j]=salary[j+1];
salary[j+1]=t;
}
for (i=0;i<number;i++)
{
cout<<salary[i]<<" ";
}
}