C++实验报告三_第1页
C++实验报告三_第2页
C++实验报告三_第3页
C++实验报告三_第4页
C++实验报告三_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 VC+程序设计实验报告 实验题目: C+语言对C语言的扩充(二) 专 学 班 指 指 日 生 级 导 导 姓 学 教 单 业 名 口 号 师 位 期 教师签名: 、实验目的 1. 学习使用 Visual C+6.0 环境的帮助。 2.学会完整的C+程序开发过程(编辑、编译、链接、调试、运行、查看结 果)。 3. 了解C+对C的扩充 二、实验内容 1.验证课本P24例题2.8、2.9 2.验证课本P30例题2.12,了解桉树重载 3.验证课本P34例题2.13、2.14,了解函数模板和模板函数 三、实验结果及其结果分析 1. 例题 2.8 1 )源程序 #include int array64

2、=60,80,90,75,75,85,65,77,820,88,90,98,89,100,78 ,81,62,68,69,75,85,85,77,91; int void main() int typeA=0,typeB=0; int student=6; int gradesize=4; for(i nt i=O;ivstude nt;i+) level(arrayi,gradesize,t yp eA,t yp eB)+; coutv nu mber of type A ist yp eAe ndl; coutv nu mber of type B ist yp eBe ndl; int

3、for(i nt i=0;i=80) return tA; else return tB; (2)运行结果: classes JI All qilobal mernben level 例题2.9 (1)源程序 #i nclude float temp二r * r * 3.14; return temp; void mai n() fn2(5.0)=12.4; (2)运行结果: :切arming ChgUU;g conwei-sion Ff-qpi double to float, possihle 1 os :learning CJt3 05: ti uncatiari Fropt * con

4、st double* to fioaf r MicrMfft 2 Microsoft V: 2.(1)源程序 #i nclude int add(i nt x,i nt y) int sum; sum=x+y; return sum; int add(int x,int y,int z) int sum; sum=x+y+z; return sum; void main() int a,b; a=add(5,10); b=add(5,10,20); couta=aendl; coutb=bendl; 2)运行结果: g *C:DocuBents and SettingsVsludV面小 a=i

5、5 b=35 PresG any key to continue. 3.例题2.13 (1)源程序 #i nclude temp late T min(T a,i nt n) int i; T minv 二a0; for(i=1;i ai) minv 二ai; return minv; void mai n() int a=1,3,027,6,4,5,2; double b=1.2,-3.4,6.8,9.8; coutvva 数组的最小值为:min(a,9)endl; coutvvb数组的最小值为:min(b,4)ent s and Sett ggslstud*桌 磁越晨:辭亀4 Press

6、any key to continue 卷攵组的戶 例题2.14 (1)源程序 #i nclude #defi ne PI 3.1415926535 temp late double Circle_Square(T x) return x * x * PI; double Circle_Square(lo ng x) return x * x * PI; void mai n() in t r1=1; double r2=2.0; long r3=3; coutvvThe first circle square isvvCircle_Square(r1)vve ndl vThe sec ond circle square isCircle_Square(r2)e ndl The third circle square isCircle_Square(r3)e ndl; classes (2)运行结果: 八DguMErvtJ anil SettinesVstudl臬eh The first cirele square is314159 The second c ii*c le square isl2 .56&4 FHe third circle square is2S.2743 Piess any key to cont iniie

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论