电大形成性考核册c++第一次作业及答案.doc

上传人:仙人指路1688 文档编号:2199473 上传时间:2023-01-29 格式:DOC 页数:7 大小:122.51KB
返回 下载 相关 举报
电大形成性考核册c++第一次作业及答案.doc_第1页
第1页 / 共7页
电大形成性考核册c++第一次作业及答案.doc_第2页
第2页 / 共7页
电大形成性考核册c++第一次作业及答案.doc_第3页
第3页 / 共7页
电大形成性考核册c++第一次作业及答案.doc_第4页
第4页 / 共7页
电大形成性考核册c++第一次作业及答案.doc_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《电大形成性考核册c++第一次作业及答案.doc》由会员分享,可在线阅读,更多相关《电大形成性考核册c++第一次作业及答案.doc(7页珍藏版)》请在三一办公上搜索。

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 en

22、ough to stop him completely.If he goes too fast or spins out of control, he has a stabilization parachute that can be deployed to slow him down. His team hopes its not needed. Instead, he plans to deploy his 270-square-foot (25-square-meter) main chute at an altitude of around 5,000 feet (1,524 mete

23、rs).In order to deploy this chute successfully, he will have to slow to 172 mph (277 kph). He will have a reserve parachute that will open automatically if he loses consciousness at mach speeds.Even if everything goes as planned, it wont. Baumgartner still will free fall at a speed that would cause you and me to pass out, and no parachute is guaranteed to work higher than 25,000 feet (7,620 meters).cause there

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

当前位置:首页 > 教育教学 > 成人教育


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号