




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、专业好文档计算机应用专业“c+语言程序设计”课程作业第一次作业一、填空题1c+语言中的每条基本语句以 ; 作为结束符,每条复合语句以 作为结束符。2用于输出表达式值的标准输出流对象是 cout ,用于从键盘上为变量输入值的标准入流对象是 cin 。3当不需要函数返回任何值时,则应把该函数类型定义为 void 。4执行“cout143+18=143+18endl;”语句后得到的输出结果为 143+18=161 。5执行“cout“ning”“chen”38endl;”语句后得到的输出结果为 ningchen38 。6在每个c+程序中都必须包含有这样一个函数,该函数的函数名为 main 。7c+源
2、程序文件的缺省扩展名为 cpp ,由c+源程序文件编译而成的目标文件的缺省扩展名为 obj ,由c+目标文件连接而成的可执行文件的缺省扩展名为 exe 。8程序运行中需要从键盘上输入多于一个数据时,各数据之间应使用 空格 或 逗号 符号作为分隔符。9十进制数25表示成符号c+语言规则的八进制和十六进制数分别为 31 和 19 符号。10在c+语言中,用转义字符序列 n 或操纵符 endl 表示输出一个换行符。11执行“coutchar(b+2)endl;”语句后得到的输出结果为 d 。12执行“coutchar(k-3)endl;”语句后得到的输出结果为 h 。13已知az的ascii码为65
3、90,当执行“int x=h+5;”语句后x的值为 77 。14已知az的ascii码为6590,当执行“char ch=16*5+2;coutchendl;语句序列后,得到的输出结果为 r 。15假定一个枚举类型的定义为“enum raxa,xb,xc,xd;”,则执行“cout”xc=”xcendl;”语句得到的输出结果为 xc=2 。16假定一个枚举类型的定义为“enum rbab,ac=3,ad,aex=ad;”则x的值为 4 。17char、short和int类型的大小分别为 1字节 、 2字节 和 4字节 。18float和double类型的大小分别为 4字节 和 8字节 。19十
4、进制数128和-3.26的类型分别为 整型 和 双精度型 。20若需要定义一个标识符常量,并且使c+能够进行类型检查,则应在定义语句的开始用保留字 define 。21使用const语句定义一个标识符常量时,则必须对它同时进行 初始化 。22执行“int x=45,y=16;coutx/yx%yz的相反表达式为 x+y5& x10的相反表达式 x=10 。34逻辑表达式ab | | b= =5的相反表达式为 ay 和x=y的逻辑值分别为 false 和 true 。36假定x=5,则执行“a=(x? 10:4*2);”语句后a的值为 10 。37假定a=5,则条件表达式“a= =0? 10:2
5、0”的值为 20 。38执行“typedef int data type;”语句后,在使用int定义整型变量的地方都可以使用 datatype 定义整型变量。39设x和y均为bool量,x & & y为真的条件是 x=true y=true 。40设x和y均为bool量,则x | | y为假的条件是 x、y都为false 。二、写出下列程序运行后的输出结果1#include void sb (char ch) switch (ch) case a :case a: cout ”well”!” ; break; case b: case b: cout ”good!” ;break; case
6、c: case c: cout ”pass!” ;break; default : cout “bad!” ; break;void main () char al=b,a2=c,a3=f; sb(al);sb(a2);sb(a3);sb(a); cout endl;good!pass!bad!well!2、#clude #includedouble sd(int a,int b,char op) double x; switch (op) case x:x=double(a) + b; break; case -: x=double (a) b; break; case * x=double
7、 (a) * b;break; case /:if (b) x=double (a)/b; else exit(1); break; default:exit(1); return x; void main ()int x=20 ,y=12;cout sd(x,y,-) ;cout sd(x,y,*) ;cout sd(x+y,y-2,/)endl;8 240 3.23、#include void main () int s=0; for (int i=1;i6;i+) s+=i*i; cout ”s=”sendl;s=554、# include void main () int s=0; f
8、or (int i=1;i+) if (s50) break; if (i%3= =0) s+=i; cout ”i,s=”i”,”sendl;i,s=19,635、# include void main ()int s1=0,s2=0;for (int i=0;i10;i+) if (i%2) s1+=i; else s2 +=i;cout s1 s2endl;25 206、# include void main ()int n=10,y=1;while (n-)y+;+y;cout ”y*y=”y*yendl;y*y=441三、写出下列每个函数的功能1include int sa(int
9、a,int b) if(ab) return 1; else if(a= =b) return 0; else return 1;比较两个整数a和b,如果a大于b则返回1;如果a等于b则返回0;如果a小于b则返回-1。2int sc(int a,int b,int c) if(a=b & a=c) return a;if(b=a & b=c) return b;if(c=a & c=b) return c;返回a、b、c三个数中的最大数。3int se(int n) / /n为大于等于1的整数int x;cinx;if(n= =1) return x;int m=x;while(n) cinx
10、; m+=x;return m;求输入的n个数之和。4double sf (double x,int n) / /n为大于等于0的整数 double p=1,s=1; for(int i=1;i=n;i+ +) p* =x;s+ =p/(i+1); return s; 计算1+x/2+x2/3+x3/4+xn/(n+1)5includebool sg(int x) / /x为大于等于2的整数 int a=int(sqrt(x);/ /取x的平方根 int i=2; while(i=a) if(x%i= =0) break; i+ +; if(ix; while(x!= 100) n+ +;y+
11、=x; cinx; if(n= =0) return y;else return y/n; 求键盘输入的数的平均值,输入-100结束(不计在平均值内),若没有数输入则返回0。if we dont do that it will go on and go on. we have to stop it; we need the courage to do it.his comments came hours after fifa vice-president jeffrey webb - also in london for the fas celebrations - said he wante
12、d to meet ivory coast international toure to discuss his complaint.cska general director roman babaev says the matter has been exaggerated by the ivorian and the british media.blatter, 77, said: it has been decided by the fifa congress that it is a nonsense for racism to be dealt with with fines. yo
13、u can always find money from somebody to pay them.it is a nonsense to have matches played without spectators because it is against the spirit of football and against the visiting team. it is all nonsense.we can do something better to fight racism and discrimination.this is one of the villains we hav
14、e today in our game. but it is only with harsh sanctions that racism and discrimination can be washed out of football.the (lack of) air up there watch mcayman islands-based webb, the head of fifas anti-racism taskforce, is in london for the football associations 150th anniversary celebrations and wi
15、ll attend citys premier league match at chelsea on sunday.i am going to be at the match tomorrow and i have asked to meet yaya toure, he told bbc sport.for me its about how he felt and i would like to speak to him first to find out what his experience was.uefa hasopened disciplinary proceedings agai
16、nst cskafor the racist behaviour of their fans duringcitys 2-1 win.michel platini, president of european footballs governing body, has also ordered an immediate investigation into the referees actions.cska said they were surprised and disappointed by toures complaint. in a statement the russian side
17、 added: we found no racist insults from fans of cska.baumgartner the disappointing news: mission aborted.the supersonic descent could happen as early as sunda.the weather plays an important role in this mission. starting at the ground, conditions have to be very calm - winds less than 2 mph, with no
18、 precipitation or humidity and limited cloud cover. the balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) where our day-to-day weather lives. it will climb higher than the tip of mount everest (5.5 miles/8.85 kilometers), drifting even higher than
19、the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. as he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.the balloon will slowly drift to the edge of space at 120,000 feet ( then, i would assume, he will slowly ste
20、p out onto something resembling an olympic diving platform.below, the earth becomes the concrete bottom of a swimming pool that he wants to land on, but not too hard. still, hell be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. it will be like he is
21、 diving into the shallow end.skydiver preps for the big jumpwhen he jumps, he is expected to reach the speed of sound - 690 mph (1,110 kph) - in less than 40 seconds. like hitting the top of the water, he will begin to slow as he approaches the more dense air closer to earth. but this will not be enough to stop
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 用电安全防火安全课件
- 模具设计中的绿色环保实践试题及答案
- 办公楼功能区装修工程可行性研究报告(模板范文)
- 快速入门游泳救生员资格试题及答案
- 模具设计师资格考试重要材料试题及答案
- 模具设计策略与实现试题及答案
- 模具设计师行业前景与考证相关试题及答案
- 明确考试目标与计划试题及答案
- 游泳救生员心理素质与团队协作研究试题及答案
- 2024年篮球裁判员知识解读试题及答案
- 海为工业物联网整体解决课件
- 电子商务数据分析教学课件汇总完整版电子教案
- 浙江省公安民警心理测验考试题目(含答案)
- (精品)3D打印机毕业论文
- 森林防火安全责任书(施工队用)
- 自卸车液压系统安装手册
- 装载机 维护保养检查记录表
- CIE1964_CIE1931_标准照明体_1nm间隔
- (完整word版)建筑工程公司员工证书管理办法
- Oring美国国家标准(AS568)
- 教育因爱幸福井晓辉
评论
0/150
提交评论