工资数据的输入

01.//02.* Copyright (c) 2013, 烟台大学计算机学院   
02.//04.* 作    者: 马德鹏   
03.//05.* 完成日期:2014 年 6 月 4 日   
04.//06.* 版 本 号:v1.0   
05.//07.*
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  double salarys[500];
  int n=0;
  while(cin>>salarys[n])
  {
      n++;
  }
  for(int i=0;i<n-1;i++)
  {
      for(int j=0;j<n-1-i;j++)
      {
          if(salarys[j]>salarys[j+1])
          {
              double t;
              t=salarys[j];
              salarys[j]=salarys[j+1];
              salarys[j+1]=t;
          }
      }
  }
  for(int i=0;i<n;i++)
  {
      cout<<salarys[i]<<"   ";
  }
  fclose(stdout);
  fclose(stdin);
  return 0;
}


猜你喜欢

转载自blog.csdn.net/u012369154/article/details/29356293