更多"有以下程序 #include <iostream> usi"的相关试题:
[填空题]有以下程序:
#include <iostream>
using namespace std;
int f(int);
int main( )
{
int i;
for(i=0;i<5;i++)
cout<<f(i)<<" ";
return 0;
}
int f(int i)
{
static int k=1;
for(;i>0;i--)
k+=i;
return k;
}
运行后的打印结果是 【9】 。
[单项选择]若有以下程序:
#include <iostream>
using namespace std;
class Base
public:
Base( )
x=0;
int x;
;
class Derivedl: virtual public Base
public:
Derivedl( )
x=10;
;
class Derived2: virtual public Base
public:
Derived2( )
(
x=20;
;
class Derived: public Derivedl,protected Derived2 ;
int main( )
Derived obj;
cout<<obj.x<<end1;
return 0;
该程序运行后的输出结果是
A. 20
B. 30
C. 10
D. 0