第十六周实验报告任务1

该系统用于管理员工工资,包括工资输入、输出、增加、排序及保存功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*
* 程序头部注释开始  
* 程序的版权和版本声明部分  
* Copyright (c) 2011, 烟台大学计算机学院学生  
* All rights reserved.  
* 文件名称:                              
* 作    者:王引琳                              
* 完成日期:2011  年 06 月 5   日  
* 版 本号:           
  
* 对任务及求解方法的描述部分  
* 输入描述: 
* 问题描述:
* 程序输出:  
* 程序头部的注释结束
*/
#include <fstream>
#include <iomanip>
#include <iostream>
using namespace std;
void ordered_salary_putout(double a[],int num);       //输出工资
void ordered_salary_puton(double a[],int num);        //输入
void ordered_salary_save(double a[],int num);         //保存
void ordered_salary_add(double a[],int num);          //增加
void ordered_salary_bubble(double a[],int num);       //排序
int main()
{
	 double a[500];
	 int num=500;
	 ordered_salary_puton(a,num);
	 cout<<"原员工工资为:"<<endl;
	 ordered_salary_putout(a,num);
	 ordered_salary_add(a,num);
	 ordered_salary_bubble(a,num);
	 cout<<"加工资排序后员工工资:"<<endl;
	 ordered_salary_putout(a,num);
	 ordered_salary_save(a,num);
	 system("pause");
	 return 0;
}
void ordered_salary_putout(double a[],int num)
{
	int i;
	for(i=0;i<num;i++)
	{
		cout << setiosflags(ios::left) << setw(10)<< a[i];
		if((i+1)%8==0)
			cout<<endl;
	}
	cout<<endl;
}

void ordered_salary_puton(double a[],int num)
{
	int i;
	ifstream infile("salary.txt",ios::in);
	if(!infile)
	{
		cerr<<"open error!"<<endl;
		exit(1);
	}
	for(i=0;i<num;i++)
	{
		infile>>a[i];
	}
	infile.close();
}
void ordered_salary_save(double a[],int num)
{
	int i;
	ofstream outfile("ordere_salary.txt",ios::out);
	if(!outfile)
	{
		cerr<<"open error!"<<endl;
		exit(1);
	}
	for(i=0;i<num;i++)
	{
		outfile<<a[i] << endl;
	}
	outfile.close();
}
void ordered_salary_add(double a[],int num)
{
	int i;
	for(i=0;i<num;i++)
	{
		a[i]=a[i]+100;
	}
}
void ordered_salary_bubble(double a[],int num)
{
	int i,j;
	double t;
	for(i=0;i<num-1;i++)
		for(j=0;j<num-i-1;j++)
			if(a[j]>a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
}


运行结果:

原员工工资为:
1648.4    619.54    1763.34   2772.59   858.74    723.49    2391      876.95

2551.5    613.3     2711.12   850.4     909.68    1213.95   1099.51   1115.36

962.57    2325.6    804.2     1900.77   2940.78   2085.27   1119.57   1784.22

1348.9    949.99    1579.13   1346.39   1822.32   678.67    1984.87   817.2

850.81    2121.39   985.94    2386.22   1112.86   1604.15   1013.89   2968.97

622.48    699.68    1034.7    1741.93   862.48    2879.14   2982.7    2513.58

2192.81   2640.22   2162.98   589.97    2277.5    1605.55   1688.42   1886.9

544.67    2410.92   1220.87   1892.87   1326.63   1696.38   1239.96   1895.55

2550.13   1946.68   2827.11   2009.47   2106.57   1401.49   2102.52   2580.97

2772.85   2809.58   2530.81   1132.66   1663.38   1974.22   1564.16   2226.63

771.3     2194.15   2620.15   2424.46   1903.66   950.45    2984.95   1942.62

 

 

加工资排序后员工工资:
634.43    644.67    648.71    653.65    654.3     660.24    672.72    673.1

685.25    689.43    689.97    692.22    696.16    699.77    711.29    713.3

714.22    719.54    722.48    734.22    740.75    743.84    748.86    766.83

778.67    780.8     781.29    788.48    794.8     795.48    799.68    805.92

810.45    823.49    828.13    829.15    841.9     846.5     848.5     857.65

863.77    871.3     873.56    878.31    879.92    882.3     891.95    892.32

902.77    904.2     917.2     925.9     928.64    931.11    931.39    932.11

933.42    944.49    945.14    950.4     950.81    951.57    953.4     958.74

962.27    962.48    962.85    964.92    972.61    976.95    981.12    995.16

997.91    999.71    1001.26   1002.29   1006.43   1009.41   1009.68   1028.37

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值