已阅读5页,还剩15页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
作业1:输入两个变量,输出两个变量的最大值。要求:使用C+语言,使用max函数完成求最大值的操作。#includeintmax(intx,inty)return(xy?x:y);intmain(intargc,char*argv)inta,b;coutab;couta;return0;作业2:(1)输入下列简单C+程序,完成编译、连接、运行,熟悉C+程序的开发过程。#includeusingnamespacestd;constfloatPI=3.1416;voidmain() intiType;floatradius,a,b,area;coutiType;switch(iType)case1:coutradius;area=PI*radius*radius;couta;coutb;area=a*b;couta;area=a*a;coutusingnamespacestd;constdoublePI=3.1416;inlinefloatcirlearea(float);inlinefloatrectarea(float);inlinefloatzrectarea(float);voidmain() intiType;floatradius,a,b,area;coutiType;switch(iType)case1:coutradius;area=cirlearea(radius);couta;coutb;area=a*b;couta;area=a*a;coutusingnamespacestd;constdoublePI=3.1416;inlinefloatcirlearea(float,float);inlinefloatrectarea(float,float);inlinefloatzrectarea(float,float);voidmain() intiType;floatradius,a,b,area;float(*carea)(float,float);coutiType;switch(iType)case1:carea=cirlearea;coutradius;area=(*carea)(radius,a=0);couta;coutb;area=(*carea)(a,b);couta;area=(*carea)(a,a);coutusingnamespacestd;classRectprivate:intlength;intwidth;intperim;public:Rect() length=10;width=10;Rect(intlength,intwidth) this-length=length;this-width=width;voidsetLength(intlength) if(length0else cout0else coutusingnamespacestd;enumcpu_wordlenW16,W32,W64,W128,W256;classCPUpublic:CPU()frequency=0;wordlength=W16;coefficient=0;coutclasspointintx,y;public:point(inta,intb)x=a;y=b;cout#includeusingnamespacestd;classStudentpublic:Student(char*,int,bool);Student(constStudentStudent();Studentvoidprint();private:char*name;intage;boolsex;intlen;Student:Student(char*name,intage,boolsex)len=strlen(name);this-name=newcharlen+1;strcpy(this-name,name);this-age=age;this-sex=sex;Student:Student(constStudentthis-name=newcharlen+1;strcpy(this-name,);this-age=stu.age;this-sex=stu.sex;Student:Student()len=0;deletename;Studentthis-name=newcharlen+1;strcpy(this-name,);this-age=stu.age;this-sex=stu.sex;return*this;voidStudent:print()cout#includeclassCMelonSalepublic:CMelonSale(floatvWeight)m_Weight=vWeight;m_TotalWeight+=m_Weight;m_WeightStore.push_back(m_Weight);m_TotalNum+;CMelonSale()m_TotalNum-;staticvoidto
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 翻译转换理论视角下的机器翻译译后编辑-《多语言发展-全球语境下的英语》(节选)英汉翻译实践报告
- 压力试验检验报告
- 执行难调研报告
- 吉安县文化馆2026年公开招聘派遣工作人员笔试安排备考题库含答案详解(能力提升)
- 2026第十四届贵州人才博览会贵州医科大学附属口腔医院引进高层次人才5人备考题库完整答案详解
- 2026浙江杭州市桐庐县凤川街道招聘编外工作人员1人备考题库含答案详解(精练)
- 2026云南楚雄州武定县事业单位选调37人备考题库附答案详解(黄金题型)
- 2026中国人民大学团委招聘1人备考题库(北京)含答案详解(典型题)
- 2026河南郑州汽车工程职业学院高层次人才招聘35人备考题库附答案详解(完整版)
- 2026上海交通大学医学院附属瑞金医院医疗岗位招聘备考题库附答案详解(夺分金卷)
- 司法鉴定学(第二版)
- 新时代国有企业荣誉体系构建与实践研究
- 2025年道路运输企业两类人员考试题库及答案
- 安宫牛黄丸会销课件
- 辽宁中医药大学中医学专业(含本硕本科段)实践教学培养方
- 老年人营养不良
- 过敏抢救流程课件
- 2025至2030中国铁路信号设备行业运营态势与投资前景调查研究报告
- 2025年国家电投笔试重点备考
- 放射药物标记-洞察及研究
- 飞行员心理健康培训课件
评论
0/150
提交评论