* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称: 第 16 周 任务 1
* 作 者: 杨森
* 完成日期: 2012 年 6 月 4 日
* 版 本 号: V1.0
源程序:
#include <fstream>
#include<iostream>
using namespace std;
int main( )
{
float a[500],t;
int i,j;
ifstream infile("salary.txt",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<500;i++)
infile>>a[i];
infile.close();
for(i=0;i<10;i++)
a[i]+=100;
for(j=0;j<500-2;j++)
{
for(i=0;i<500-j-1;i++)
if (a[i]>a[i+1])
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
}
ofstream outfile("ordered_salary.txt",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<500;i++)
{
outfile<<a[i]<<endl;
if(i%5==0) cout<<endl;
cout<<a[i]<<"\t";
}
outfile.close();
system("pause");
return 0;
}
运行结果:
小感:又回到一个main函数就是一个程序的时候了啊