报告1:(到底完成了哪个任务,必须声明清楚)
实验目的:学会循环语句的使用
实验内容:编程序,求解1/2-2/3+3/4-…+19/20(或1/3-3/5+5/7-7/9…+19/21)
// 以下是我编制的程序
#include <iostream> using namespace std; int main( ) { <wbr>double sum=0; <wbr>int i=0; <wbr>while (i<=19) <wbr>{ <wbr><wbr>i=i+1; <wbr><wbr><wbr><wbr><wbr><wbr><wbr> sum=sum+float(i)/(i+1); <wbr><wbr>i=i+1; <wbr><wbr>sum=sum-float(i)/(i+1); <wbr>} <wbr>sum=sum+float(20)/21; <wbr><wbr><wbr> cout<<"sum="<<sum<<endl;<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> ;//在必要的位置上给出行注释 <wbr><wbr><wbr> return 0; } </wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
运行结果: 经验积累:我学会了如何进行强制类型转换
上机感言:实践是检验真理的唯一标准。
报告2:
实验目的:学会用循环结构解决实际问题
实验内容:划算的交易?
// 以下是我编制的程序
#include <iostream> using namespace std; int main( ) { <wbr>double i=1,m=30,k=0.01,Poor=0; <wbr>while (i<=m) <wbr>{ <wbr><wbr>Poor=Poor+k; <wbr><wbr>k=2*k; <wbr><wbr>i=i+1; <wbr>} <wbr><wbr><wbr> cout<<"Poor="<<Poor<<endl; <wbr><wbr><wbr> double d=1,u=30,x=100000,Rich=0; <wbr>while (d<=u) <wbr>{ <wbr><wbr>Rich=Rich+x; <wbr><wbr>d=d+1; <wbr>} <wbr><wbr><wbr> cout<<"Rich="<<Rich<<endl; <wbr><wbr><wbr> return 0; } 运行结果: <a href="http://photo.blog.sina.com.cn/showpic.html#blogid=8db23fd10100usb8&url=http://s6.sinaimg.cn/orignal/8db23fd14afa4fc4d3395" target="_blank"><img title="第九周实验报告" name="image_operate_81851042340179812" alt="第九周实验报告" src="http://s6.sinaimg.cn/middle/8db23fd14afa4fc4d3395&690" width="669" height="438"></a> <a href="http://photo.blog.sina.com.cn/showpic.html#blogid=8db23fd10100usb8&url=http://s6.sinaimg.cn/orignal/8db23fd14afa4fe5a1c45" target="_blank"></a> 经验积累: </wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
1. cout遇到空格就停止???
2.
3.
上机感言: