/* (程序头部注释开始)
* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:设计一个工资类(Salary)--完成各个功能
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
float a[500];
ifstream infile("salary.txt",ios::in);
if(! infile)
{
cerr << "open error!" << endl;
exit(1);
}
for(int i = 0;i < 500;i++)
{
infile >> a[i];
}
infile.close();
for(int i = 0; i < 500; i++)
{
a[i] += 100;
}
for(int j = 0;j < 500; j++)
{
for(int k = 0; k <500 - j - 1; k++)
{
if(a[k + 1] < a[k])
{
float t;
t = a[k + 1];
a[k + 1] = a[k];
a[k] = t;
}
}
}
ofstream outfile("salary.txt",ios::app);
if(! outfile)
{
cerr << "open error!" << endl;
exit(1);
}
for(int i = 0;i < 500; i++)
{
outfile << a[i] ;
if(i % 10 == 0)
{
cout<<endl;
}
cout<<a[i]<<"\t";
}
cout << endl;
outfile.close();
system("pause");
return 0;
}
![](https://img-my.csdn.net/uploads/201206/04/1338805765_6246.jpg)