1、C+程序设计模拟题三、用 C+语言描述下列命题1、A 小于 B 并且 A 大于 C2、A 和 B 中有个小于 C3、A 是奇数4、B 和 C 中较大者与 A 相等5、年份 Y 是闰年四、写出下列程序的执行结果1.#include void main()int b35=11,12,13,14,15,21,22,23,24,25,31,32,33,34,35;int (*p)5;p=b;for(int j=0;jvoid swapl(int a,int b)int temp=a;a=b;b=temp;void swap2(int*a,int*b) int temp=*a; *a=*b,*b=tem
2、p;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);coutvoid print(int w)int i;if(w!=0)print(w-1);for(i=1;i#define sw(x,y) x=y;y=x;x=y;void main()int a=10,b=01;sw(a,b);cout void main( )int a,b,c,x;a=b=c=0;for (int k=0; kx;switch(x%3)case 0:a+
3、=x; break;case 1:b+=x; break;case 2:c+=x; break;cout void main( )int j,k;for (j=5; j0; j-)for (k=j; k0; k-)coutvoid main()int nNumber;int *pPointer;nNumber = 15;pPointer = coutint *pPointer;void SomeFunction()pPointer = new int;*pPointer = 25;void main()SomeFunction(); coutvoid AddFive(int* Number)*
4、Number = *Number + 5;void main()int nMyNumber = 18;coutvoid main()int Array3;Array0 = 10;Array1 = 20;Array2 = 30;int *pArray;pArray = coutint i=4; void main()coutvoid fun( );void main( )fun( );fun( );void fun( )static int a=1;int i=5;a+;i+;coutclass Pointpublic:Point(int xx=0, int yy=0) X=xx; Y=yy;
5、countP+; Point(Point int GetX( ) return X;int GetY( ) return Y;void GetC( ) coutint addDefault(int x=1,int y=2);void fun(void);void main(void) int addDefault(int x=3,int y=4);coutvoid main()int m,n,a=3,b=3,number;number=237;m=number/5;n=number%5;coutvoid main()int width,height,result1,result2,result
6、3;height=3;width=5;result1=height3 result2=height3 | width=5;result3=!(width=5);coutvoid main() int i=32,j=6;double df;df=i/j+2.3;coutint c10;void add(int x,int y)static int i=0;ci=x+y;i+;void main()int a10=1,2,3,4,5,6,7,8,9,10;int b10=10,9,8,7,6,5,4,3,2,1;int i=0,k=0;for(i=0;ivoid main()char s30=“c
7、omputer,mouse,key“;int i=0,k=0;coutvoid main()char s=“C+ program“;char *ps1=“computer“; char *ps2,*ps3=s;ps2=“mouse“;coutint 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;coutmn;e=fun1(m,n); d=m*n/e;coutvoid main()int a34=1,2,3,4,3,4,5,6,5,6,7,8;int b43,i,
8、j;for(i=0;i#include void main()const int m=5;int amm;int i,j;for(i=0;ivoid main()char s30=“computer,mouse,key“;int i=0,k=0;cout#include struct studentchar num5;char name10;char sex;int age;float mathscore;void main()struct student st10=“001“,“Wangping“,f,19,84,“002“,“Zhaomin“,m,20,64,“003“,“Wanghong
9、“,f,18,54,“004“,“Lilei“,m,19,92,“005“,“Liumin“,m,19,75;int i,k=0;float average=0;for(i=0;ivoid main()int b34=23,38,16,12,56,89,66,34,58,12,90,100;int i,j,m=3,n=4;for(i=0;i=00;j-)cout=0;i-) for(j=0;jvoid main()int a=12,22,32,42,52,62,72,82,92,102;int i, m=5;int *p=a;for(i=0;i=0;i-)coutvoid main()int
10、b24=12,36,62,14,56,98,74,63;int (*p)4=b;int i,j;for(i=0;i=0;j-)cout#include void main() int func(int a,int b,char op);int (*fptr)(int a,int b,char op);fptr=func;coutstruct studentchar *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 int10;for(int i=0;inum=“12“;stp-name=“Li“;stp-age=18;coutnumnameageclass Pointpublic:Point(int xx=0,int yy=0)X=xx; Y=yy;cout#include class Point public:Point(int xx=0, int yy=0) X=xx;Y=yy;coutclass Basepublic:Base(int x,int y) a=x; b=y; void Show() coutShow();pb=pb-Show();