#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<fstream>
using namespace std;
int main( )
{
ifstream infile("a.txt",ios::in);
if(!infile)
{
cerr<<"open error"<<endl;
exit(1);
}
//这里是要编写的代码
double salarys[500] , t;
for(int l=0;l<500;l++)
{
infile>>salarys[l];
}
infile.close();
for (int m=0;m<500;m++)
{
salarys[m]*=2;
}
//将n名职工的工资排序后输出
for(int i=0;i<500-2;i++)
{
for(int j=0;j<500-i-1;j++)
{
if(salarys[j]<salarys[j+1])
{
t=salarys[j];
salarys[j]=salarys[j+1];
salarys[j+1]=t;
}
}
}
ofstream outfile("b.txt",ios::out);
if(!outfile)
{
cerr<<"open error"<<endl;
exit(1);
}
for (int x=0;x<500;x++)
{
outfile<<salarys[x]<<" ";
if(x%5==0) outfile<<endl;
}
outfile.close();
return 0;
}
运行结果