更多"下面程序的执行结果为 #include' iostream' "的相关试题:
[单项选择]下面程序的执行结果为 ‘ #include"iostream" using namespace std; class A { int a; public: void Sera(int x){a=x;} void Display_a( ){cout<<a<<endl;} }; class B { int b; public: void Setb(int x){ b=x;} void Dispaly_b( ) {cout<<b<<endl;} }; class C://public A,private B { private: int c; public: void Setc(int x,int y,int z) { c=z;Sera(x);Serb(y);} void Display_c( ){cout<<c<<endl;} }; ① void main( ) ② { ③ C cc; ④ cc.Seta(1); ⑤ cc.Display_a( ); ⑥ cc.Setc(2,2,3); ⑦ cc.Dispaly_b( ); ⑧ cc.Display_c( ); }
A. 输出为2 2 3
B. 有错误在第5行
C. 输出为1 2 3
D. 有错误在第7行
[单项选择]下面程序的执行结果为
#includ"iostream"
using namespace std;
class A
{
int a;
public:
void Seta(int x){a=x;}
void Display_a( ){cout<<a<<endl;}
};
class B
{
int b;
public:
void Setb(int x){b=x;}
void Dispaly_b( ){cout<<b<<endl;}
};
class C:public A,private B
{
private:
int c;
public:
void Setc(int x,int y,int z)
{c=z;Seta(x);Setb(y);}
void Display_c( ){cout<<c<<endl;}
};
① void main( )
② {
③ C cc;
④ cc.Seta(1);
⑤ cc.Display_a( );
⑥ cc.Setc(2,2,3);
⑦ cc.Dispaly_( );
⑧ cc.Display_c( );
}
A. 输出为2 2 3
B. 有错误在第5行
C. 输出为1 2 3
D. 有错误在第7行
[简答题]请给出下面程序的输出结果
#include<iostream>
using namespace std;
void fun( )
static int n=25;
n--:
cout<<"n="<<n<<endl:
void main( )
for(int i=0;i<=2;i++)
fun( );
[单项选择]给出下面程序的输出结果。
#include<iostream>
using namespace std;
void main( )
int num=0,i=8;
do
i--;
num++;
while(--i);
cout<<nun<<endl;
[填空题]下面程序的输出结果为 【7】 。
#include <iostream>
using namespace std;
void initialize(int printNo,int state=0);
void initialize(int printNo=1,int state);
int main( ) initialize( );
return 0;void initialize(int printNo, int state) cout<<printNo<<","<<state<<end1;
[填空题]下面程序的输出结果为 【6】 。
#include <iostream>
using namespace std;
void initialize(int printNo,int state=0);
void initialize(int printNo=1,int state);
int main( ) initialize( );
return 0;void initialize(int printNo, int state) cout<<printNo<<","<<state<<end1;
[填空题]下面程序的运行结果是 【10】 。
#include<iostream>
using namespace std;
class count static int n;
public:
count( )
n++;
static int test( )
for(int i=0;i<4;i++)
n++;
return n;
;
int count::n = 0;
int main( ) cout<<count :: test( )<<" ";
count c1, c2;
cout<<count :: test( )<<end1;
return 0;
[填空题]阅读下面程序:
#include <iostream>
using namespace std;
int fun( int a, int b)
{
int c;
c = a * b;
return c;
}
int main ( )
{
int a = 3, b = 5, c = 4, x = O;
x = fun( fun( a, b ), c );
cout<<x<<end1;
return 0;
}
其运行结果是 【9】 。
[填空题]阅读下面程序:
#include<iostream>
using namespace std;
long fib(int n)
if ( n > 2 )
return (fib(n-1)+fib(n-2));
else
return 2;
int main( )
cout<<fib(3)<<end1;
return 0;
则该程序的输出结果应该是 【8】 。
[填空题]有以下面程序:
#include <iostream>
using namespace std;
long fib(int n)
{
if (n>2)
return (fib(n-1)+fib(n-2));
else
return 2;
}
int main( )
{
cout<<fib(3)<<endl;
return 0;
}
则该程序的输出结果应该是 【12】 。
[填空题]有以下面程序:
#include<iostream>
using namespace std;
long fib(int n)
{
if (n>2)
return(fib(n-1)+fib(n-2));
else
return 2;
}
int main( )
{
cout<<fib(3)<<end1;
rcturn 0;
}
则该程序的输出结果应该是 【12】 。