Salary.h
class Salary
{
public:
void cin_salary ();
void up_salary ();
void rsalary ();
void cout_salary();
private:
double salary[50];
int number ;
};
原文件
T41.cpp
#include <iostream>
#include "Salary.h"
using namespace std;
int main()
{
Salary sal;
sal.cin_salary();
sal.up_salary();
sal.rsalary();
sal.cout_salary();
system("PAUSE");
return 0;
}
资源文件
T42.cpp
#include <iostream>
#include "Salary.h"
using namespace std;
void Salary::cin_salary()
{
int i=0;
cout<<"请输入数据"<<endl;
for (i=0;i<=50;i++)
{
cin>>salary[i];
if (salary[i]==-1)
break;
}
i--;
number=i;
}
void Salary::up_salary()
{
int i=0;
for(i=0;i<=number;i++)
{
salary[i]=salary[i]+100;
}
}
void Salary::rsalary()
{
int j,i;
double t;
j=0,i=0;
for(j=0;j<number;j++)
for (i=0;i<number-1;i++)
{
if(salary[i]<salary[i+1])
{
t=salary[i];
salary[i]=salary[i+1];
salary[i+1]=t;
}
}
}
void Salary::cout_salary()
{
int i=0;
for (i=0;i<=number;i++)
{
cout<<salary[i]<<'\t';
}
}