编写一个程序,已有若干学生的数据,包括学号,姓名,成绩,要求输出这些学生的数据并计算出学生人数和平均成绩
2015-06-30 09:48
1526 查看
#include<iostream>
#include<string>
using namespace std;
class student
{
public:
void show()
{
cout<<"num="<<num<<endl;
cout<<"name="<<name<<endl;
cout<<"score="<<score<<endl;
}
static void show1()
{
cout<<"the numbers of students:"<<count<<endl;
cout<<"the aver score of students:"<<aver<<endl;
}
student(string num1,string name1,double score1)
{
num=num1;
name=name1;
score=score1;
count++;
sum+=score1;
aver=sum/count;
}
private:
string num;
string name;
double score;
static double sum;
static int count;
static double aver;
};
double student::sum=0.0;
int student::count=0;
double student
4000
::aver=0.0;
int main()
{
student stu1("14","小红",78);
stu1.show();
student stu2("24","小蓝",90);
stu2.show();
student stu3("25","小敏",85);
stu3.show();
student::show1();
return 0;
}
#include<iostream>
#include<string>
using namespace std;
class student
{
public:
void show()
{
cout<<"num="<<num<<endl;
cout<<"name="<<name<<endl;
cout<<"score="<<score<<endl;
}
static void show1()
{
cout<<"the numbers of students:"<<count<<endl;
cout<<"the aver score of students:"<<aver<<endl;
}
student(string num1,string name1,double score1)
{
num=num1;
name=name1;
score=score1;
count++;
sum+=score1;
aver=sum/count;
}
private:
string num;
string name;
double score;
static double sum;
static int count;
static double aver;
};
double student::sum=0.0;
int student::count=0;
double student
4000
::aver=0.0;
int main()
{
student stu1("14","小红",78);
stu1.show();
student stu2("24","小蓝",90);
stu2.show();
student stu3("25","小敏",85);
stu3.show();
student::show1();
return 0;
}
相关文章推荐
- android 横竖屏切换
- JS将UTC格式日期字串转换成日期DATE对象
- 七天学会ASP.NET MVC (三)——ASP.Net MVC 数据处理
- 第1章 游戏之乐——NIM(2)“拈”游戏分析
- python实现的简单FTP上传下载文件实例
- Android Studio常用快捷键
- css3 鼠标移入移出效果
- 开源中国GIT中Java分类下TOP10项目的活动情况分析
- bzoj1043
- android 包的获取方式
- 极客学院录制课程合集
- JS将科学计数法字串转换成正常数值
- LWIP实现网络远程IAP下载更新
- python初步学习
- JS中showModalDialog 详细使用(转)
- CentOS:[10]6.4 x64 minimal安装后的基本设置
- Eclipse设置相同变量背景色高亮显示
- 《开源框架那点事儿13》:基于开源框架做应用是未来中小型软件公司的发展趋势
- maven项目配置Project Facets时further configuration available不出来问题
- python之import引用