第十六周实验报告1
来源:互联网 发布:手机网页广告过滤 知乎 编辑:程序博客网 时间:2024/06/06 20:38
*
(程序头部注释开始)* 程序的版权和版本声明部分* Copyright (c) 2011, 烟台大学计算机学院学生* All rights reserved.* 文件名称:设计一个工资类(Salary)--完成各个功能 * 作 者: 刘程程* 完成日期: 2012年* 版 本 号:V1.2 * 对任务及求解方法的描述部分* 输入描述: ...* 问题描述: ...* 程序输出: ...*程序头部的注释结束*/ #include <iostream>#include <fstream>using namespace std;class Salary{public: void ordered_salary_add(); void ordered_salary(); void input_salary(); void ordered_salary_txt();private: double salary[500]; int number;};int main(){ Salary s1; //cout<<"500人得原始工资为:"<<endl; s1.input_salary (); //cout<<endl; cout<<"排序后工资为:"; cout<<endl; s1.ordered_salary(); cout<<endl; s1.ordered_salary_txt(); system("PAUSE"); return 0;}void Salary::input_salary (){ int i=0; ifstream infile("salary.txt",ios::in); if(!infile) { cerr<<"open error!"<<endl; system("PAUSE"); exit(1); } for (i=0;i<500;i++) infile>>salary[i]; infile.close(); number=500;}void Salary::ordered_salary_add(){ int i; for(i=0;i<number;i++) { salary[i]=salary[i]+100; //cout<<salary[i]<<" "; } return;}void Salary::ordered_salary(){ int i,j; double t; for(i=0;i<number-1;i++) { for(j=0;j<number-1-i;j++) { t=salary[j]; salary[j]=salary[j+1]; salary[j+1]=t; } for(i=0;i<number;i++) { cout<<salary[i]<<" "; } return; }}void Salary::ordered_salary_txt(){ ofstream outfile("ordered_salary.txt",ios::out); if(!outfile) { cerr<<"open error!"<<endl; exit(1); } for(int i=0;i<500;i++) outfile<<salary[i]<<"\n"; outfile.close(); return;}
运行结果:
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告1
- 第十六周实验报告(1)
- 第十六周实验报告(1)
- 第十六周实验报告任务1
- 第十六周实验报告2
- 第十六周实验报告3
- 第十六周实验报告2
- 第十六周实验报告2
- 第十六周实验报告2
- 第十六周实验报告2.0
- 第十六周实验报告3
- 第十六周实验报告3
- 2012.6.3ref 用法
- 黑马程序员_java学习笔记四
- 算法:12?56? * 123 =154?4987 求问号的值
- HDU 1003 Max Sum
- php优化
- 第十六周实验报告1
- 2012.6.3关于ReferenceEquls 和Equls
- 带感应系统的彩票选号器(详解)
- SQL 连接的定义
- IE9 不能显示本地图片问题
- warning: function declaration isn't a prototype
- grub的用法简介
- Android ApiDemos示例解析(17):App->Activity->Translucent Blur
- 镜头