收藏 分销(赏)

C.语言程序设计试题试题及答案.pdf

上传人:w****g 文档编号:2577926 上传时间:2024-06-01 格式:PDF 页数:50 大小:120.33KB
下载 相关 举报
C.语言程序设计试题试题及答案.pdf_第1页
第1页 / 共50页
C.语言程序设计试题试题及答案.pdf_第2页
第2页 / 共50页
C.语言程序设计试题试题及答案.pdf_第3页
第3页 / 共50页
C.语言程序设计试题试题及答案.pdf_第4页
第4页 / 共50页
C.语言程序设计试题试题及答案.pdf_第5页
第5页 / 共50页
点击查看更多>>
资源描述

1、C ,C+(120)1.Cmain(C)A.B.C.D.2.(B)A.+1e+1 5e-9.4 03e2B.-.60 12e-4-8e5C.123e 1.2e-.4+2e-1D.-e3.8e-4 5.e-03.a=-14,b=3,ab?a:b+1(A)A.-14 B.-13 C.3 D.44.:int n,i=1,j=2;n=ij?i+:j+;ij(c).A.1,2 B.1,3 C.2,2 D.2,35.s1s2,(D)A.if(s1=s2)B.if(s1=s2)C.if(strcmp(s1,s2)D.if(strcmp(s1,s2)=0)6.(B)A.B.C.D.7.C(D)A.B.C.D.

2、8.(A)A.B.C.D.9.(D)A.double fun(int x,int y)z=x+y;return z;B.fun(int x,y)int z;return z;C.fun(x,y)int x,y;double z;z=x+y;return z;D.double fun(int x,int y)double z;z=x+y;return z;10.(B)#include#define F(y)8.19-y#define PRINT(a)printf(%d,(int)(a)void main(void)int x=2;PRINT(x*F(3);A.10 B.13 C.11 D.11.

3、(C)A.A.void main(void)unionint n;float x;comm=1;printf(%d,comm.n);B.B.void main(void)unionint n;float x;comm=12.5;printf(%f,comm.x);C.C.void main(void)unionfloat x;int n;comm=12.5printf(%f,comm.x);D.D.void main(void)unionint n;float x;comm=5;printf(%d,comm.n);12.int a=1,*p=&a;float b=2.0;char c=A;(A

4、)A.p+;B.a-;C.b+;D.c-;13.scanfa-(B)main()int*p,*q,a,b;p=&a;printf(input a:);scanf(%d,*p);-A.*ppB.*pa aC.*ppD.*pp14.numabcintnum=(a=4,b=16,c=32);num(C)A.4 B.16 C.32 D.5215.,a1,a2,c1,c210,20,AB,(C),(:_)int al,a2,char c1,c2;scanf(%d%c%d%c,&a1,&c1,&a2,&c2);A.10A_20_B B.10_A_20_B C.10A20B D.10A20_B16.int

5、a10;a(C)A.a10 B.a3.5 C.a5-3 D.a-117.C,;(A)A.B.C.D.18.a(C)A.in a10=(0,0.0,0,0);B.int a10=;C.int a0;D.int a10=10*1;19.(C)x=-1;dox=x*x;while(!x);A.-B.-C.-D.20.do-while-(B)A.do-while-B.do-while-dowhilewhile()C.do-while-while()D.do-while-(115)1.CT2.T3.whiledo-while-T4.-continue-F5.01T6.int a34=0a000 T7.T

6、8.T9.0F10.F11.F12.T13.14.i+i15.(15)1.if a0,(ABC).Aa0B!aCa=0DaEa!=02.(CEGIJ)A3e22.5B-e-3C-.1e-1DBASICE045F0fdG0 xfdaLHe8IJ3.-(ADFHI)(1)(2)-(3)int(4)-(5)(6)(7)C(8)(9)C(10)C4.,5(ABDEH)(1)(2)(3)papapa(4)int*pintp(5)(6)int a4,*p=a,p+pa(7)(8)(9)(10)pa2a4p=p*25.5(BEGHI)(1)(2)(3)(4)int a3=0,1,2,b3;b=aba(5)C

7、(6)char c11;c=china;(7)char s15=I am a0 student;,strlen(s)6(8)C(9)C(10)(420)1.(4)()#includevoid main(void)int i;char a=Time,b=Tom;for(i=0;a!=0&b!=0;i+)if(a=b)if(a=a&a=z)printf(%c,a-32);else printf(%c,a+32);else printf(*);2.(4)()i=1;s=3dos+=i+;if(s%7=0)continue;else+i;whlie(s=0&x=3000&x=6000&x=10000)

8、y=54+0.3*x;printf(%6.1f,y);4.(4)()void main(void)int a=1,k;for(k=0;k3;k+)printf(%4d,f1(a)int f1(int x)static int z=3,y=0;y+;z+;return(x+y+z);5.(4)F(x,y,z)=(x+y)/(x-y)+(z+y)/(z-y)#include#includefloat fun1(float,float);void main(void)float x,y,z,sum;scanf(%f%f%,&x,&y,&z);sum=fun1()+fun1();printf(sum=

9、%fn,sum);float fun1(float a,float b)float num;num=a/b;return num;(220)1.:/6=1/(11)+1/(22)+1/(33)+.,10e-6#include#include void main(void)long i=1;pi=0;while(i*i=10e+6)pi=;i+;pi=sqrt(6.0*pi);printf(pi=%10.6fn,pi);2.str13void main(void)char str143=A,b,C,d,E,f,G,h,I,j,K,i;int x,y,z;for(x=0;x1)#includein

10、t age(int n)int c;if(n=1)c=10;else c=;return c;4.void main(void)int year,yes;scanf(%d,&year);if(year%400=0)yes=1;else if()yes=1;else ;if(yes)printf(%d is,year);else printf(%d is not,year);printf(a leap year.n);5.:,void main(void)int x,y,z,c;scanf(%d%d%d,&x,&y,&z);if()c=y;y=z;z=c;if()c=x;x=z;z=c;if()

11、c=x;x=y;y=c;printf(%d,%d,%d,x,y,z);(120)1.Cfloat();double()1A)c B)C)W D)2C+:A)WHILE B)user C)_1var D)9stars3_int i=0;while(i25)i+=3;couti;A)24 B)25 C)27 D)284C+_A)radius B)foobar C)else D)3room5ainta=25/3%3A)3 B)2 C)1 D)06A)B)C)D)7A B C D8char s10;s1As+1 B*(s+1)C&s0+1 D&s19A B C D10A BC D1_1_2_2_3_4

12、_3C+classstruct_5_6_4int a=3,b=2;ab?a:b_(7)_526%3=_(8)_32/5=_(9)_6_(10)_(11)_(12)_(13)_(14)_(15)_(16)_7 (17)8C+(18)(19)9nn=(float)2/3 (20)1include#include class CRectprivate:char color10;int left;int top;int length;int width;public:CRect();CRect(char*c,int t,int lef,int len,int wid);void SetColor(ch

13、ar*c);void SetSize(int l=100,int w=100);void Move(int t,int l);void Draw();CRect:CRect()strcpy(color,Black);top=0;left=0;length=0;width=0;CRect:CRect(char*c,int t,int lef,int len,int wid)strcpy(color,c);top=t;left=lef;length=len;width=wid;void CRect:SetColor(char*c)strcpy(color,c);void CRect:SetSize

14、(int l,int w)length=l;width=w;void CRect:Move(int t,int l)top=t;left=l;void CRect:Draw()cout (left ,top )endl;cout length ,width endl;cout color endl;void main()CRect r;r.SetColor(Red);r.Move(10,20);r.SetSize(100,200);r.Draw();r.Move(50,50);r.SetColor(Blue);r.Draw();2#include class Aint x,y;public:A

15、()x=0;y=0;A(int a,int b)x=a;y=b;A()if(x=y)cout x=y endl;elsecout x!=y endl;void Display()cout x=x ,y=y endl;void main()A a1,a2(2,3);a1.Display();a2.Display();3#include class Aprivate:int n;public:A(int i)n=i;operator+()n+;operator+(int)n+=2;void Display()cout n=n endl;void main()A a(2),b(2);a+;+b;a.

16、Display();b.Display();4#include int func1(int n);int func2(int n);void main()int sum;sum=func2(5);cout sum endl;int func1(int n)if(n=1)return 1;elsereturn n*func1(n-1);int func2(int n)int s=0;for(int i=1;i=n;i+)s+=func1(i);return s;11234#include#include class Aprivate:_(1)_protected:_(2)_public:A(in

17、t a,int b,int c)X=a;Y=b;Z=c;int GetX()return X;int GetY()return Y;int GetZ()return Z;class B _(3)_private:int K;public:B(int a,int b,int c,int d)_(4)_K=d;void Show()cout GetX()GetY()Z K endl;void main()B b(1,2,3,4);c.Show();230sfunc1246-565860s0s1s2-s27 s28 s29func25ws0s1s2 s3s4w0s5s6s7 s8s9w1-#incl

18、ude#include void func1(double s)int i,k;for(k=2,i=0;i 30;i+)si=k;_(5)_void func2(double s,double w)double sum;int i,k;for(k=0,i=0,sum=0;i30;i+)_(6)_if(i+1)%5=0)wk=sum/5;_(7)_k+;void main()double s30,w6;func1(s);func2(s,w);C+1C2.D3.A4.A5.B6.D7.D8.A9.c10.b1 2.3.class struct4.25.2 66.7.public private p

19、rotect 8.cpp .h9.0.5150,50100,100Blue2x=0,y=0 x=2,y=3x=yx!=y3n=3n=44 51.int X,Y;2.int Z;3public A4:A(a,b,c)5k+=2;6sum+=si;7sum=0;C+2011_1_ 2_2_3_3_4_5_4_(6)_(7)_/5_(8)_(9)_6_(10)_(11)_7_(12)_(13)_8_(14)_(15)_9.abmain()char a=I am a boy.,b20;int i;for(i=_(16)_;ai!=0;i+)_(17)_;_(18)_;101-3+5-7+-99+101

20、s#include main()int i,t=1,s=0;for(i=1;i=101;_(19)_)s=s+i*t;t=_(20)_;1021-2C+classstruct3double x35x3 14-53021int a,b;a=5;b=a+;cout b;A)4 B)5 C)6 D)72int i,a;for(i=0;i=10;i+)a=i;cout i;A)0 B)9 C)10 D)113_A)B)C)D)4 int*p1,*p2,a10;p1=a;p2=&a5;p2-p1A)B)10 C)5 D)125A)B)C)D)6._A)B)C)D)70ASCII48void main()

21、char a=1,b=2;cout b+,;cout b-a endl;A 3,2 B50,2 C2,2 D2,508void main()int a33,*p,i;p=&a00;for(i=0;i9;i+)pi=i;for(i=0;i3;i+)cout a1i;A012 B123 C234 D3459AdoubleBCD10void main()int a=1,2,3,4,5,6,7,8,9,0,*p;for(p=a;pa+10;p+)cout *p ,;A1,2,3,4,5,6,7,8,9,0,B2,3,4,5,6,7,8,9,10,1,C0,1,2,3,4,5,6,7,8,9,D1,1,

22、1,1,1,1,1,1,1,1,11void main()int c=35;int b=c&c;cout b;A0 B70 C35 D112int i=0,s=1;while(i3)s+=i;i+;cout s;A)5 B)6 C)4 D)313char a7=abcdef;char b4=ABC;strcpy(a,b);cout a5;A)e B)f C)0 D)14A)int Fun(int x,int y=2,int z=3);B)int Fun(int x=1,int y,int z=3);C)int Fun(int x,int y=2,int z);D)int Fun(int x=1

23、,int y,int z);15A)B)C)D)20101sub1sub#include long sub(int num)int i;long subsum=1;for(i=1;i=num;i+)subsum*=i;return(subsum);void main()int i;long sum=0;for(i=1;i=5;i+)sum+=sub(i);cout i ,sum endl;2#include class Basepublic:void WhoAmI()cout Class Bass endl;virtual void Who()cout Class Bass endl;clas

24、s Derived:public Basepublic:void WhoAmI()cout Class Derived endl;void Who()cout Class Derived WhoAmI();p-Who();p=&d;p-WhoAmI();p-Who();20101Convert#include int Convert(char*str);void main()char s10=12345;int n=Convert(s);cout n endl;int Convert(char*str)int num=0,digit;for(int i=0;(1);i+)digit=(2);n

25、um=num*10+digit;return num;2Convert#include int Convert(char*str);void main()char s10=12345;int n=Convert(s);cout n endl;int Convert(char*str)int num=0,digit;for(int i=0;(3);i+)digit=(4);num=num*10+digit;return num;C+1void2.3.4.5.6.7.8.9.ai=bi ai=010.i=i+212.3.4.5.1C2B3A4D5B6.D7.B8.A9.D10.B11.D12.B1

26、3.A14.C15.D1.1num5,1532Class BassClass BassClass DerivedClass Derived1(1)i strlen(str)(2)stri2(1)i10(2)siC+:2011-07-17 18:54:admin:2840:C+1char array=Chinaarray A)4 B)5 C)6C+1char array=ChinaarrayA)4 B)5 C)6 D)72_A)B)C)D)3ainta=1000999A)0 B)1 C)2 D)34for-int i=10;for(i=1;i10;i+)cout *;A)9 B)10 C)8 D

27、)75void main()int a33,*p,i;p=&a00;for(i=0;i9;i+)pi=i;for(i=0;i3;i+)cout a1i;A012 B123 C234 D3456AdoubleBC?ldquo;D7void main()int a=1,2,3,4,5,6,7,8,9,0,*p;for(p=a;pa+10;p+)cout *p ,;A1,2,3,4,5,6,7,8,9,0,B2,3,4,5,6,7,8,9,10,1,C0,1,2,3,4,5,6,7,8,9,D1,1,1,1,1,1,1,1,1,1,8template T func(T x,T y)return x*

28、x+y*y;funcA)func(3,5);B)func(3.0,5.5)C)func(3,5.5)D)func(double)3,5.5)9class Aint x;public:A(int n)x=n;class B:public Aint y;public:B(int a,int b);A)B:B(int a,int b):x(a),y(b)B)B:B(int a,int b):A(a),y(b)C)B:B(int a,int b):x(a),B(b)D)B:B(int a,int b):A(a),B(b)10A)B)C)D)1p_1_2_2_3_3_4_5_4-switch _(6)_

29、51-3+5-7+-99+101s#include main()int i,t=1,s=0;for(i=1;i=101;_(7)_)s=s+i*t;t=_(8)_;6C+-_9_7_10_11_12_13_14_15_16_8_17_18_9_19_20_123doublex35x5145C+struct6class789101#include class Personpublic:Person()cout Construct Person endl;Person()cout Destruct Person endl;class Student:public Personpublic:Stud

30、ent()cout Construct Student endl;Student()cout Destruct Student endl;class Teacher:public Personpublic:Teacher()cout Construct Teacher endl;Teacher()cout Destruct Teacher endl;void main()Student s;Teacher t;2#include class AApublic:static int n;AA()n+;int AA:n=0;void main()coutAA:n=AA:n endl;AA d1;c

31、outd1.n endl;AA d2;coutd2.n endl;AA d3,d4;coutd1.n endl;coutd2.n endl;1abcc#include#include void main()int a10=1,3,5,7,9,13,17,21,27,30;int b10=2,4,6,8,10,12,14,16,18,20;int c20;int i=0,j=0,k=0;while(j10)&(k10)if(aj bk)(1);j+;else(2);k+;i+;if(j10)while(j10)(3);j+;i+;if(k10)while(k10)(4);j+;i+;for(i=

32、0;i20;i+)cout setw(5)ci;if(i=9)cout endl;2=truefalse#include class complexprivate:double real,imag;public:complex(double r,double i)real=r;imag=i;bool operator=(complex&);bool complex:operator=(complex&com)return(_(5)_)void main()complex c1(12.3,32.5),c2(21.7,18.6);if(_(6)_)couttruen;elsecoutfalsen;

33、C+31C2.c3.b4.A5.A6.C7.A8.C9.D10.B1*P2.3.4.break5.i+=2 -t6.false7.8.public protected private protected public9.1 2 3.4.5.6.7.8.1Construct PersonConstruct StudentConstruct PersonConstruct TeacherDestruct TeacherDestruct PersonDestruct StudentDestruct Person2AAn=01244(1)ci=aj (2)ci=bk(3)ci=aj(4)ci=bk(5)(real-com.real)&(imag-com.imag)?1:0(6)c1=c2.B

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 通信科技 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服