C++程序设计综合练习题-读程序写结果题_第1页
C++程序设计综合练习题-读程序写结果题_第2页
C++程序设计综合练习题-读程序写结果题_第3页
C++程序设计综合练习题-读程序写结果题_第4页
C++程序设计综合练习题-读程序写结果题_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

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

文档简介

C 程序设计模拟题 三 用 C 语言描述下列命题 1 A 小于 B 并且 A 大于 C 2 A 和 B 中有 个小于 C 3 A 是奇数 4 B 和 C 中较大者与 A 相等 5 年份 Y 是闰年 四 写出下列程序的执行结果 1 include void main int b 3 5 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 int p 5 p b for int j 0 j 5 j cout p j cout endl 2 include void swapl int a int b int temp a a b b temp void swap2 int a int b int temp a a b b temp void swap3 int a int b int temp a a b b temp void swap4 int a b b temp void main int a 10 b 20 swapl a b cout a b endl swap2 cout a b endl swap3 cout a b endl swap4 a b cout a b endl 3 if w 0 print w 1 for i 1 i w i cout w cout endl void main print 4 4 include define sw x y x y y x x y void main int a 10 b 01 sw a b cout a b 5 假定输入 10 个整数 32 64 53 87 54 32 98 56 98 83 下列程序的输出 结果是什么 a b c 0 for int k 0 k x switch x 3 case 0 a x break case 1 b x break case 2 c x break cout a b c endl 6 include void main int j k for j 5 j 0 j for k j k 0 k cout cout endl 7 include void main int nNumber int pPointer nNumber 15 pPointer cout nNumber is equal to nNumber endl pPointer 25 cout nNumber is equal to nNumber endl 8 include int pPointer void SomeFunction pPointer new int pPointer 25 void main SomeFunction cout Value of pPointer pPointer endl delete pPointer 9 include void AddFive int Number Number Number 5 void main int nMyNumber 18 cout My original number is nMyNumber endl AddFive cout My new number is nMyNumber endl 10 include void main int Array 3 Array 0 10 Array 1 20 Array 2 30 int pArray pArray cout pArray points to the value endl cout pArray endl cout pArray 1 endl 11 include int i 4 void main cout i i endl i 5 int i i 7 cout i i endl cout i i 12 include void fun void main fun fun void fun static int a 1 int i 5 a i cout i i a a endl 13 Y yy countP Point Point int GetX return X int GetY return Y void GetC cout Object id countP endl private int X Y static int countP Point Point Point Y p Y countP int Point countP 0 void main Point A 4 5 cout Point A A GetX A GetY A GetC Point B A cout Point B B GetX B GetY B GetC 14 include int addDefault int x 1 int y 2 void fun void void main void int addDefault int x 3 int y 4 cout addDefault endl fun int addDefault int x int y cout x y return x y void fun void cout addDefault endl 15 include void main int m n a 3 b 3 number number 237 m number 5 n number 5 cout m m endl cout n n endl a m b n cout a a endl cout b b endl 16 include void main int width height result1 result2 result3 height 3 width 5 result1 height 3 result2 height 3 width 5 result3 width 5 cout result1 result1 endl cout result2 result2 endl cout result3 result3 endl 17 include void main int i 32 j 6 double df df i j 2 3 cout df df endl i df 3 cout i i endl 18 void add int x int y static int i 0 c i x y i void main int a 10 1 2 3 4 5 6 7 8 9 10 int b 10 10 9 8 7 6 5 4 3 2 1 int i 0 k 0 for i 0 i 10 i add a i b i for i 0 i 10 i cout c i 19 include void main char s 30 computer mouse key int i 0 k 0 cout s endl while s i 0 if s i m 通过数组名和下标引用数组元素 k i cout i i endl cout k k endl 20 include void main char s C program char ps1 computer char ps2 ps3 s ps2 mouse cout s ps1 ps2 ps3 endl ps1 ps2 2 ps3 4 cout s 4 ps1 ps2 ps3 endl cout s ps1 ps2 ps3 endl ps1 s 21 如果输入的数据是 24 和 18 则下列程序的输出结果是什么 include int fun1 int c int d int r r c d while r 0 c d d r r c d return d void main int m n e d cout m n e fun1 m n d m n e cout e endl cout d endl 22 include void main int a 3 4 1 2 3 4 3 4 5 6 5 6 7 8 int b 4 3 i j for i 0 i 3 i for j 0 j 4 j cout a i j cout endl for i 0 i 4 i for j 0 j 3 j b i j a j i for i 0 i 4 i for j 0 j 3 j cout b i j cout endl 23 include include void main const int m 5 int a m m int i j for i 0 i m i a i 0 1 a i i 1 for j 1 j i j a i j a i 1 j 1 a i 1 j for i 0 i m i for int k 0 k 30 2 i k cout for j 0 j i j cout setw 5 a i j cout endl 24 include void main char s 30 computer mouse key int i 0 k 0 cout s endl while s i 0 if s i m k i cout i i endl cout k k endl 25 include include struct student char num 5 char name 10 char sex int age float mathscore void main struct student st 10 001 Wangping f 19 84 002 Zhaomin m 20 64 003 Wanghong f 18 54 004 Lilei m 19 92 005 Liumin m 19 75 int i k 0 float average 0 for i 0 i 5 i average st i mathscore average 10 cout average average endl for i 0 i 5 i if st i mathscore 60 k cout st i num st i name st i sex cout st i age st i mathscore endl cout k endl 26 include void main int b 3 4 23 38 16 12 56 89 66 34 58 12 90 100 int i j m 3 n 4 for i 0 i m i for j 0 j n j cout b i j cout endl for i 0 i 20 i cout cout endl for i 0 i 00 j cout b i j cout endl for i 0 i 20 i cout cout 0 i for j 0 j n j cout b i j cout endl 27 include void main int a 12 22 32 42 52 62 72 82 92 102 int i m 5 int p a for i 0 i m i cout p cout 0 i cout p i cout endl 28 include void main int b 2 4 12 36 62 14 56 98 74 63 int p 4 b int i j for i 0 i 2 i for j 0 j 4 j cout p i j cout endl for i 0 i 20 i cout cout endl for i 0 i 0 j cout p i j cout endl 29 include include void main int func int a int b char op int fptr int a int b char op fptr func cout func 3 5 endl cout fptr 3 5 endl int func int a int b char op switch op case cout a op b return a b break case cout a op b return a b break case cout a op b return a b break default cout Operator error endl return 0 30 include struct student char num char name int age void main int ip float fp char cp struct student stp fp new float 32 6 cp new char cp A ip new int 10 for int i 0 inum 12 stp name Li stp age 18 cout fp cp endl cout num num name name age age endl for i 0 i 10 i cout ip i cout endl delete cp delete fp delete ip delete stp 31 include class Point public Point int xx 0 int yy 0 X xx Y yy cout 构造函数被调用 endl Point Point int GetX return X int GetY return Y private int X Y Point Point Point Y p Y cout 拷贝构造函数被调用 endl Point fun2 Point A 1 2 return A void fun1 Point p cout p GetX endl void main Point A 1 2 fun1 A Point B A cout B GetX endl B fun2 cout B GetX endl 32 include include class Point public Point int xx 0 int yy 0 X xx Y yy cout 构造函数被调用 endl Point Point int GetX return X

温馨提示

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

评论

0/150

提交评论