更多"#include<iostream.h> class A "的相关试题:
[填空题]
[程序]
#include
int f2(int *a,int b)
{
*a=*a+b; b=*a+b;
cout<<"*a="<<*a<<"/t"<<"b="<
return *a+b;
}
void f1(int a,int &b)
{
a=a+b;b=a+b;
b=f2(&a,b);
cout<<"a="< }
void main(void)
{
int x=4,y=5;
f1(x,y);
cout<
}
执行以上程序后输出的第一行是(),第二行是(),第三行是()
[填空题]
[程序]
#include
#include
class B{
public:
B(char *s){name=new char[strlen(s)+1];strcpy(name,s);}
virtual void print( ){cout<<"姓名;"<
protected:
char *name;
};
class P1:public B{
public:
P1(char *s,float g):B(s){x=g;}
void print(int i)
{ cout<<"姓名:"<年薪:"<万元。 /n";}
private:
float x;
};
class P2:public B{
public:
P2(char *s,int n):B(s){ num=n;}
void print( ){cout<<"姓名;"<月工资:"<元。/n";}
private:
int num;
};
void main(void)
{
B *p;
B x("张明");
P1 y("王虎",4.2);
P2 z("李建国",5000);
p=&x;p->print( );
p=&y;p->print( );
y.print(1);
p=&z;p->print( );
}
执行以上程序后输出的第二行是() ,第四行是()。
[填空题]#include<stdio.h>
int add(int a,int b)
{int c;
c=a+b:
return c;
}
void print(int t)
{printf("z=%d/n",t);}
main( )
{int x,y,z;
x=1;y=2;
z=add(x,y);
print(z);
}
程序运行结果是:______
[填空题]
[程序]
#include
int f(int a,int &b,int *c)
{
a+=b; b+=*c;*c+=a;
return (a+b+*c);
}
void main(void)
{
int x=5,y=5,z=6,sum;
for(int i=0;i<2;i++){
sum=f(x,y,&z);
cout<
}
}
执行程序后输出的第一行是___(1)___,第二行是___(2)___。
[单项选择]有以下程序
#include
void fun(int a,int b,int C)
a=456,b=567,c=678;
void main( )
int x=10,y=20,z=30;
fun(x,y,z);
cout < < x < < ’,’ < < y < <’,’ < < z < < end1;
输出结果是
A. 30,20,10
B. 10,20,30
C. 456,567,678
D. 678,567,456
[单项选择]有以下程序
#include
void fun(int a,int b)
{ int t;
t=a;a=b;b=t;
}
main( )
{ int c[10]={1,2,3,4,5,6,7,8,9,0},i;
for(i=0;i<10;i+=2) fun(c[i],c[i+1]);
for(i=0;i<10;i++) printf("%d,",c[i]);
printf("/n");
}
程序的运行结果是
A. 1.2,3,4,5,6,7,8,9,0,
B. 2,1,4,3,6,5,8,7,0,9,
C. 0,9,8,7,6,5,4,3,2,1,
D. 0,1,2,3,4,5,6,7,8,9,
[填空题]有如下程序
#include<stdio.h>
int rune(int a,int b)
{return(a+b);)
main( )
{int x=2,y=5,z=8,r;
r=rune(rune(x,y),z);
printf("%dkn",r);
}
该程序的输出结果是______。
[填空题]阅读下面程序:
#include <iostream.h>
int fun( int a, int b )int c;
c=a*b;
return c;void main( )int a=3,b=5,c=4,x=0;
x=fun(fun(a, b),c);
cout<<x<<end1;其运行结果是 【9】 。
[单项选择]有以下程序:
#include <stdio.h>
int add(int a, int b){return(a+b); }
main( )
{ int k, (*f)( ), a=5, b=10;
f=add;
...
}
则以下函数调用语句错误的是______。
A. k=f(a, b);
B. k=add(a, b);
C. k=(*f)(a, b);
D. k=*f(a, b);
[单项选择]有如下程序
#include<iostream.h>
int func(int a,int b)
return(a+b);
void main( )
int x=2,y=5,z=8,r;
r=func (func (x,y),z);
cout<<r;
该程序的输出的结果是
A. 12
B. 13
C. 14
D. 15
[单项选择]若类A和类B的定义如下:
#include<malloc.h>
class A
int i j;
public:
int geti( )
return i;
;
class B:public A
int k;
public:
void make( )
k=i*j;
;
A. k=i*j;
B. intk;
C. return i;
D. void make();
[单项选择]有以下程序:
#include <stdio.h>
int fun(int a,int b)
if(b==0) return a;
else return (fun(--a,--b));
main( )
printf("%d/n", fun(4, 2));
程序的运行结果是( )。
A. 1
B. 2
C. 3
D. 4