没有合适的资源?快使用搜索试试~ 我知道了~
首页设计一个学生类(CStudent)
设计一个学生类(CStudent)
![](https://csdnimg.cn/release/wenkucmsfe/public/img/star.98a08eaa.png)
设计一个学生类(CStudent),它具有的私有数据成员是注册号、姓名、数学、外语、计算机课程的成绩。具有的公有成员函数是:求三门课总成绩的函数sum,求三门课平均成绩的函数average,显示学生数据信息的函数display,设置学生数据信息的函数setData.然后通过主函数从键盘对学生对象的数组(全班学生信息)进行输入,而后求出每一个学生的总成绩、平均成绩,并显示全班学生总成绩最高的同学的全部数据信
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/3210024/bg1.jpg)
#include "stdafx.h"
#include <iostream.h>
#include <iomanip.h>
#include <string.h>
#include <stdio.h>
const int nn=3;
const int maxlen=20;
class CStudent{
private:
char *sno;
char *sname;
int score[3];//score[0] means math, score[1] means English and the rest is com
puter
public:
int ssum();
double average();
void display(){
cout<<"the output is:"<<setw(12)<<sno<<setw(10)<<sname<<setw(10)<<s
sum()<<setw(12)<<average()<<endl;
}
void setData(char *no,char *name,int *sscore,int n);
};
int CStudent::ssum (){
int sum=0;
for(int i=0;i<3;i++) sum=sum+score[i];
return sum;
}
double CStudent::average (){return (double)ssum()/3.0;}
void CStudent::setData (char *no,char *name,int *sscore,int n)
{
sno=new char[strlen(no)+1];
strcpy(sno,no);
sname=new char[strlen(name)+1];
strcpy(sname,name);
for(int i=0;i<n;i++) score[i]=*(sscore+i);
}
int main(int argc, char* argv[])
{
CStudent stu[nn];
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![text/x-c++](https://img-home.csdnimg.cn/images/20210720083646.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![](https://profile-avatar.csdnimg.cn/e54bfcc770ca4e9691fccecf6e4290a2_jiaogepengyouba.jpg!1)
jiaogepengyouba
- 粉丝: 2
- 资源: 13
上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
会员权益专享
最新资源
- 基于嵌入式ARMLinux的播放器的设计与实现 word格式.doc
- 经典:大学答辩通过_基于ARM微处理器的嵌入式指纹识别系统设计.pdf
- 嵌入式系统课程设计.doc
- 基于飞思卡尔控制器的智能寻迹车设计ARM基础课程课程设计.doc
- 下载基于ARM7的压电陶瓷换能器导纳圆测量仪的研制PDF格式可编辑.pdf
- 课程设计基于ARM的嵌入式家居监控系统的研究与设计.doc
- 论文基于嵌入式ARM的图像采集处理系统设计.doc
- 嵌入式基于ARM9的中断驱动程序设计—课程设计.doc
- 在Linux系统下基于ARM嵌入式的俄罗斯方块.doc
- STK-MirrorStore Product Release Notes(96130)-44
- STK-MirrorStore Storage Connectivity Guide for StorageTek Disk A
- 龙虾养殖远程监控系统的设计与实现数据采集上位-机软件模块-本科毕业设计.doc
- 龙虾养殖远程监控系统的设计与实现数据采集上位-机软件模块-.doc
- 龙虾养殖远程监控系统的设计与实现数据采集上位-机软件模块-本科生毕业论文.doc
- 麻阳风貌展示网站的设计与实现毕业论文.pdf
- 高速走丝气中电火花线切割精加工编程设计.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)