第十六周实验报告任务1
来源:互联网 发布:网络免费打电话软件下载 编辑:程序博客网 时间:2024/05/21 15:46
/** 程序头部注释开始 * 程序的版权和版本声明部分 * 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
- 第十六周实验报告任务1
- 第十六周实验报告(任务一)
- 第十六周实验报告(任务二)
- 第十六周实验报告任务3--电子词典
- 第十六周实验报告任务2
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周任务报告1
- C++程序设计实验报告(七十九)---第十六周任务一
- C++程序设计实验报告(八十)---第十六周任务二
- C++程序设计实验报告(八十一)---第十六周任务三
- 第十六周实验报告 任务三(最简)
- 第十六周实验报告(任务一)【涨工资】
- 判断一个数是否是2的幂数,并且判断是多少次方
- datax测试 读mysql 写hdfs
- 十六周任务一
- JAVA特殊语法
- android 关机流程分析
- 第十六周实验报告任务1
- 链表进行了翻转
- 字符串提取数字
- Android listView滑动刷新代码(分页功能)
- ConcurrentHashMap解析
- clock 、times 、gettimeofday
- fedora14 编译android2.3 找不到zlib.h
- QTP SystemUtil对象
- Android structure