《C++程序设计》实验报告格式Word格式.docx

上传人:b****4 文档编号:8161992 上传时间:2023-05-10 格式:DOCX 页数:13 大小:70.32KB
下载 相关 举报
《C++程序设计》实验报告格式Word格式.docx_第1页
第1页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第2页
第2页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第3页
第3页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第4页
第4页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第5页
第5页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第6页
第6页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第7页
第7页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第8页
第8页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第9页
第9页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第10页
第10页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第11页
第11页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第12页
第12页 / 共13页
《C++程序设计》实验报告格式Word格式.docx_第13页
第13页 / 共13页
亲,该文档总共13页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

《C++程序设计》实验报告格式Word格式.docx

《《C++程序设计》实验报告格式Word格式.docx》由会员分享,可在线阅读,更多相关《《C++程序设计》实验报告格式Word格式.docx(13页珍藏版)》请在冰点文库上搜索。

《C++程序设计》实验报告格式Word格式.docx

陈东明

组号:

实验日期:

2010年3月26日

实验时间:

14时00分-17时20分

实验成绩:

批阅教师签字:

一、实验目的

(1)学习编写简单的C++程序,并掌握C++程序的基本格式与规范。

(2)理解C++程序结构的特点。

(3)掌握函数的定义和调用方法。

(4)练习重载函数的使用。

(5)练习函数模板的使用。

(6)练习使用系统函数。

(7)学习使用VC++的debug调试功能,使用stepinto追踪到函数内部。

二、实验内容与实验步骤

实验内容:

(1)输人并运行所给的参考程1,并将程序中的注释部分也输人计算机,体会和理解程序的基本格式规范。

(2)编写一个函数把华氏温度转换为摄氏温度,转换公式为C=(F一32)*5/9。

(3)编写重载函数Maxl可分别求取两个整数,三个整数,两个双精度数,三个双精度数的最大值。

(4)使用重载函数模板重新实现上小题中的函数Maxl。

(5)使用系统函数pow(x,y)计算xy的值,注意包含头文件math.h。

(6)用递归的方法编写函数求Fibonacci级数,观察递归调用的过程。

原理分析:

1:

intadd(inta,intb)

{

intc;

c=a+b;

returnc;

}

2:

intzhuang(inta)

intx;

x=(a-32)*5/9;

returnx;

3:

intMax1(inta,intb)

return((a>

b)?

a:

b);

intMax1(inta,intb,intc)

return((c>

((a>

b))?

c:

b));

doubleMax1(doublea,doubleb)

doubleMax1(doublea,doubleb,doublec)

4:

template<

classT>

TMax1(Ta,Tb)

TMax1(Ta,Tb,Tc)

5:

intx,y,z;

cout<

<

"

pleaseinputtwonumber:

\n"

;

cin>

>

x>

y;

z=pow(x,y);

theresultis:

z<

endl;

return0;

6:

intfib(intn)

if(n==1)

x=1;

else

if(n==2)

x=1;

else

x=fib(n-1)+fib(n-2);

三、实验环境

操作系统:

windowsXP

开发平台的名称及版本:

MicrosoftVisualC++6.0

四、实验过程与分析

--------------------Configuration:

oier-Win32Debug--------------------

Compiling...

iwedf.cpp

\programfiles\microsoftvisualstudio\myprojects\oier\iwedf.cpp(8):

errorC2065:

'

cout'

:

undeclaredidentifier

errorC2297:

'

illegal,rightoperandhastype'

char[25]'

endl'

\programfiles\microsoftvisualstudio\myprojects\oier\iwedf.cpp(9):

cin'

warningC4552:

operatorhasnoeffect;

expectedoperatorwithside-effect

\programfiles\microsoftvisualstudio\myprojects\oier\iwedf.cpp(11):

char[17]'

Errorexecutingcl.exe.

oier.exe-5error(s),1warning(s)

通过比较书中的范例找到未写usingnamespacestd;

写后问题解决。

五、实验结果总结

1

2

3

4

5

6

六、思考题

1.VisualC++6.0环境下是如何管理项目和文件的?

2.C++提供的输入输出操作与C语言的输入输出操作的异同点?

3.C++引入的内联函数与其它函数有何不同?

4.重载函数时通过什么来区分?

七、参考文献

Visualc++面向对象的程序设计

八、附录

intmain()

intx,y,sum;

Entertwonumber:

x;

sum=add(x,y);

cout<

thesumis:

sum<

intadd(inta,intb)//求和

intc,f;

pleaseinputthenumber:

f;

c=zhuang(f);

temperatureis:

c<

intzhuang(inta)//转换成温度

inta,b,c,d;

doublef,x,y,z;

pleaseinputtwointnumber:

\n"

a>

b;

d=Max1(a,b);

cout<

theMaxis:

d<

pleaseinputthreeintnumber:

b>

c;

d=Max1(a,b,c);

pleaseinputtwodoublenumber:

f>

y=Max1(f,x);

y<

pleaseinputthreedoublenumber:

z;

y=Max1(f,x,z);

intMax1(inta,intb)//比较两个整数大小

intMax1(inta,intb,intc)//比较三个整数大小

doubleMax1(doublea,doubleb)//比较两个浮点数大小

doubleMax1(doublea,doubleb,doublec)//比较三个浮点数大小

TMax1(Ta,Tb)//比较两个数大小

TMax1(Ta,Tb,Tc)//比较三个数大小

intx,y,z;

//求幂

intn,f;

n;

f=fib(n);

theFibonacciis:

f<

intfib(intn)//递归函数

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2