《C++语言程序设计》程序设计初步(一).doc_第1页
《C++语言程序设计》程序设计初步(一).doc_第2页
《C++语言程序设计》程序设计初步(一).doc_第3页
《C++语言程序设计》程序设计初步(一).doc_第4页
《C++语言程序设计》程序设计初步(一).doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

淮海工学院计算机科学系实验报告书课程名: C+语言程序设计 题 目: 程序设计初步(一) 班 级: 软件102班 学 号: 111003215 姓 名: 鹿迅 评语:成绩: 指导教师: 批阅时间: 年 月 日C语言程序设计实验报告1、 实验内容或题目(1)教材41-42页第3-8题;(2)给出一个百分制的成绩,要求输出成绩等级A,B,C,D,E。90分以上的为A,8089分的为B,7079分的为C,6069分的为D,60分以下的为E。(要求使用switch语句)(3)输出所有的“水仙花数”,所谓的“水仙花数”是指一个3位数,其各位数的立方和等于该数本身。例如,153是一个水仙花数,因为,153135333。2、实验目的与要求(1)进一步熟悉熟悉VC+6编译环境,掌握运用VC编译C程序的基本方法;(2)学会使用C+的常用运算符,以及包含这些运算符的表达式; (3)掌握常见的流程控制结构(顺序、选择),学会运用这两种控制结构编写C+程序。3、 实验步骤与源程序 实验步骤前十八题比较简单,我都是看书上的例题,把语句输进去,注意一下细节就可以了。而后两题比较复杂,可能是我接触不久的原因,需要想很久,而且上机好几次,才最终运行成功,花费了很多时间和精力,像许多同学和学长请教才成功。 源代码1.#include using namespace std;int main()char c1=a,c2=b,c3=c,c4=101,c5=116;coutc1c2c3n;couttbc4tc5n;return 0;2#include using namespace std;int main()char c1=C,c2=+,c3=+;coutI say:c1 c2 c3 ;coutttHe says:C+ is very interesting !n;return 0;3#include using namespace std;int main()int a=12;a/=a+a;coutaendl;return 0; 4#include using namespace std;int main()double a;a=26/3+34%3+2.5;coutaendl;return 0;5#include using namespace std;int main()int a;a=45/2+(int)3.14159/2;coutaendl;return 0;6#include using namespace std;int main()int a=3,b,c;a=b=(c=a+=6);coutaendl;return 0;7#include using namespace std;int main()int a,b;a=3*5,a=b=3*2;coutaendl;return 0;8#include using namespace std;int main ()int a=5,b,s;s=(int)(a+6.5)%2+(a=b=5);coutsendl;return 0;9#include using namespace std;int main()double x=2.5,y=4.7;int a=7,z;z=x+a%3*(int)(x+y)%2/4;coutzendl;return 0;10#include using namespace std;int main()double a=2,b=3,x=3.5,y=2.5,z;z=(float)(a+b)/2+(int)x%(int)y;coutzendl;return 0;11#include using namespace std;int main()int a=12;a+=a;coutaendl;return 0;12#include using namespace std;int main()int a=12;a-=3;coutaendl;return 0;13#include using namespace std;int main()int a=12;a*=2+3;coutaendl;return 0;14#include using namespace std;int main()int a=12;a/=a+a;coutaendl;return 0;15#include using namespace std;int main ()int a=12,n=5;a%=(n%=2);coutaendl;return 0;16 #include using namespace std;int main ()int a; a+=a-=a*=a; coutaendl;return 0; 17#include using namespace std;int main ()int i,j,m,n;i=8;j=10;m=+i+j+;n=(+i)+(+j)+m;coutitjtmtnendl;return 0;18#include using namespace std;int main()char c1,c2,c3,c4,c5;c1=C;c2=h;c3=i;c4=n;c5=a;c1=c1+4;c2=c2+4;c3=c3+4;c4=c4+4;c5=c5+4;coutc1c2c3c4c5n;return 0;19#include using namespace std;int main ()int x, g;cing;if (90=g) x=9;else if (80=g) x=8;else if (70=g) x=7;else if (60=g) x=6;else x=5;switch (x)case 9:coutAn;break;case 8:coutBn;break;case 7:coutCn;break;case 6:coutDn;break;case 5:coutEn;break;default:couterrorn;break;coutendl;return 0;20#include using namespace std;int main()int i,j,k,d;for (i=1;i=9;i+)for (j=0;j=9;j+)for(k=0;k=9;k+)d=100*i+10*j+k;if (d=i*i*i+j*j*j+k*k*k)coutdendl;return 0;4试数据与实验结果(可以抓图粘贴)第1题第1题第2题题

温馨提示

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

最新文档

评论

0/150

提交评论