文档详情

C++程序设计实验报告模板 (500字).doc

发布:2017-05-14约2.58千字共5页下载文档
文本预览下载声明
C++程序设计实验报告模板 (500字) 重庆邮电大学 (2014-2015学年第一学期) C++程序设计随课实验报告 指导教师:姓 名:学 号: 2014210127 班 级: 0101404 电 话: 第一部分:实验内容 (包括实验题目、对应的源程序及程序运行截图) 1:.输入一个年份,判断该年份是否闰年,如果是就输出YES,否则输出NO。 #includelt;iostream.hgt; void main() { int year,k; cingt;gt;year; if((year%4==0amp;amp;year%100!=0)||(year%400==0)) coutlt;lt;yearlt;lt;quot;是闰年。quot;lt;lt;endl; else coutlt;lt;yearlt;lt;quot;不是闰年。quot;lt;lt;endl; coutlt;lt;quot;关闭,请按任意数字再按enter.quot;lt;lt;endl; cingt;gt;k; } 2.输入3个数a,b,c,要求按由小到大的顺序输出。 #includelt;iostream.hgt; void main() { int a,b,c,max,m; cingt;gt;agt;gt;bgt;gt;c; max=a; if(alt;b) max=b; if(blt;c) max=c; coutlt;lt;quot;亲!最大值是quot;lt;lt;maxlt;lt;quot;哦。quot;lt;lt;quot;按任意字母或数字再enter离开。quot;lt;lt;endl; cingt;gt;m; } 3.输入两个数,进行四则运算,输出其和·差·积·商。 #includelt;iostream.hgt; void main() {int a,b,c,d,q,o,i; cingt;gt;agt;gt;b; c=a+b; d=a-b; q=a*b; o=a/b; cout.precision(3); coutlt;lt;quot;和:quot;lt;lt;clt;lt;endl; coutlt;lt;quot;差:quot;lt;lt;dlt;lt;endl; coutlt;lt;quot;乘积:quot;lt;lt;qlt;lt;endl; coutlt;lt;quot;商(整数):quot;lt;lt;olt;lt;endl; coutlt;lt;quot;任意数字后确定退出:quot;; cingt;gt;i; } 4.用cout语句打印一个三角图形。 * * * * * * #includelt;iostream.hgt; void main() { int a; coutlt;lt;quot; quot;lt;lt;quot; quot;lt;lt;quot;*quot;lt;lt;endl; coutlt;lt;quot; quot;lt;lt;quot;*quot;lt;lt;quot; quot;lt;lt;quot; quot;lt;lt;quot;*quot;lt;lt;endl; coutlt;lt;quot;*quot;lt;lt;quot; quot;lt;lt;quot; quot;lt;lt;quot;*quot;lt;lt;quot; quot;lt;lt;quot; quot;lt;lt;quot;*quot;lt;lt;endl; coutlt;lt;quot;任意字母数字确定退出:quot;; cingt;gt;a; } 第二部分:总结与体会(50-200字) (针对本学期《C++程序设计》课程学习,说说自己的收获、疑问、建议等) 刚刚步入C++,学习制作了几个最基础的程序,感觉对输入输出入有了初步了解。但在浮点和循环方面都不懂,没理解到意思,记不住。发现现在做的都是整数,不知道怎么弄小数。希望老师能够都讲解这方面。
显示全部
相似文档