第四章作业4.21
2015-06-27 01:42
316 查看
#include<iostream> #include<iomanip> #include<string> using namespace std; class student{ private: float score; public: string number; //学生学号; string name; //学生姓名; static int sum; //学生总人数; static float sumscore; //学生总成绩; static float aver; //学生平均成绩; void show(); static void count(); student(string n,string num,float s) { number=num; name=n; score=s; ++sum; sumscore=sumscore+score; aver=sumscore/sum; } }; int student::sum=0; float student::sumscore=0; float student::aver=0.0; void student::show() { cout<<"姓名为:"<<name; cout<<" 学号为:"<<number; cout<<"的学生的成绩为:"<<score<<endl; } void student::count() { cout<<"学生总人数为:"<<sum<<endl; cout<<"学生总成绩为:"<<sumscore<<endl; cout<<"学生平均成绩为:"<<aver<<endl; } int main() { student stu1("aaa","10000000",87),stu2("ddd","20000000",92),stu3("www","30000000",88),stu4("qqq","40000000",90); stu1.show(); stu2.show(); stu3.show(); stu4.show(); cout<<endl; student::count(); return 0; }
相关文章推荐
- KVO、通知、代理、block
- 正则表达式精华(包涵常用经典方法)
- Android中ListView的几种常见的优化方法
- 使用Volley解析json
- drupal drupal drupal 你家养的猪娃跑了
- Django用自定义cookies 实现登录,注册,退出
- Android的EditText字数检测和限制
- CentOS 6.x 内核升级(2.6.32 -> 3.10.58)过程记录
- 上门洗车APP --- Android客户端开发 之 网络框架封装介绍(二)
- Composer PHP依赖管理的新时代
- Struts2 Hibernate Integration Example Tutorial
- #leetcode#Distinct Subsequences
- 【POJ 1125】Stockbroker Grapevine
- 一个有趣的swap函数
- Android中dp和px之间进行转换
- onkeyup,onkeydown和onkeypress
- C#编写Windows服务程序图文教程
- Best MVC Practices(最优的MVC布局)
- POJ 3268 Silver Cow Party 最短路 基础题
- eclipse黑底背景的设置