* Copyright (c) 2012, 烟台大学计算机学院
* All rights reserved.
* 作 者:庄子豪
* 完成日期:2012 年 11月29 日
* 版 本 号:v1.0
*
* 输入描述:
* 问题描述:
* 程序输出:
* 问题分析:
*算法设计
#include <fstream>
#include <iostream>
using namespace std;
void paixu(double a[],int n);
int main()
{
double a[500];
int i;
ifstream infile("salary.txt",ios::in);
if(!infile)
{
cerr<<"open error"<<"\n";
exit(1);
}
for(i=0;i<500;i++)
infile>>a[i];
infile.close();
for(i=0;i<500;i++)
a[i]=a[i]+100;
paixu(a,500);
ofstream outfile("order_salary.txt",ios::out);
if(!outfile)
{
cerr<<"open error!"<<"\n";
exit(1);
}
for(i=0;i<500;i++)
{
outfile<<a[i]<<'\t';
}
outfile.close();
cout<<"\n";
return 0;
}
void paixu(double a[],int n)
{
int i,j,k;
double t;
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(a[j]<a[k])
k=j;
t=a[k];
a[k]=a[i];
a[i]=t;
}
}