値上がりした

1378 ワード

/*
*             
* Copyright (c)2012,            
* All rightsreserved.
*     : h.cpp                           
*       :                             
*     :  2012   12    1 
*    : 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&&i!=0) cout<<endl;
                cout<<a[i]<<"\t";
           }
           outfile.close();     
            return 0;
}

実行結果:
......