更多"在下面程序横线处填上适当内容,使得程序的输出为9876。
#in"的相关试题:
[填空题]在下面程序横线处填上适当内容,使得程序的输出为9876。
#include <iostream>
using namespace std;
template<class T>
void f( 【12】 )
T t;
for (int i=0;i<n/2;i++)
t=a Ii];
a [i]=a[n-1-i];
a [n-1-i]=t;
int main ( )
int x[]=6,7,8,9;
f(x,4);
for (int i=0;i<4;i++)
cout<<x[i];
cout<<end1;
return 0;
[填空题]在下面程序横线处填上适当内容,使程序输出为:55599。
#include <iostream>
using namespace std;
template <class TYPE>
class HisClass
TYPE data;
public:
HisClass(TYPE a, TYPE b, TYPE C) ;
TYPE getData( ) return data;)
;
template<class TYPE>
HisClass<TYPE>::HisClass(TYPE a,TYPE b,TYPE C)
【12】 ;
else主f(b>C)
data=b;
else
data=c;
int main( )
HisClass<int> x1(3,4,5),x2(5,3,4),x3(4,5,3),x4(7,8,9),x5(8,7,9);
cout<<x1.getData( )<<x2.getData( )<<x3.getData( )
<<x4.getData( )<<X5.getData( );
return 0;
[填空题]在下面程序横线处填上适当内容,以使该程序执行结果为4.4。
#include<iostream>
using namespace std;
template<typename T>
T average(T*datA)
T s=0;
int i:0;
while(data[i])
【12】 ;
return s/(i+1);
int main( )
double x[]=2.5,4.5,6.5,5,0.0,12.5,23.3,18.5;
cout<<average(X);
return 0;
[简答题]在下面程序中的横线处填上适当内容,使程序完整
#include<iostream.h>
______
class A
int i;
public:
int set(B&);
int get( )return i;
A(int x)i=x;
;
class B
int i;
public:
B(int x)i=x;
______A;
;
int A::set(B &b)
return i=b.i:
void main( )
A a(1);
B b(2);
cout<<a.get( )<<",";
a.set(b);
cout<<a.get( )<<endl;
[填空题]在下面程序的横线处填上适当的语句,使该程序的输出为12。
#include <iostream>
using namespace std;
class Base
public:
int a;
Base(int i)a=i;
;
class Derived: public Base
int a;
public:
Derived(int x): Base(x),b(x+l)
void show( )
【11】 ;∥输出基类数据成员a的值。
cout<<b<<end1;
;
int main( )
Derived d(1);
d.show( );
return 0;
[填空题]在下面的程序的横线处填上适当的语句,是该程序的输出为12。
#include<iostream>
using namespace std;
class Base
public:
int a;
Base(int i)a=i;
;
class Derived:public Base
int a;
public:
Derived(int x):Base(x),b(x+1)
void show( )
【11】 ; //输出基类数据成员a的值。
cout<<b<<endl;
;
int main( )
Derived d(1);
d.show( );
return 0;
[填空题]在下面的程序的横线处填上适当的语句,使该程序的输出为12。
#include<iostream.h>
using namespace std;
class Base
{
public:
int a,b;
Base(int i){a=i;}
};
class Derived:public Base
{
int a;
public:
Derived(int x):Base(x),b(x+1){};
void show( )
{
______;//输出基类数据成员a的值
cout<<b<<endl;
}
};
int main( )
{
Derived d(1);
d.show( );
return 0;
[简答题]在下面程序横线处填上适当的语句,使其输出结果为0,15,15。
#include<iostream.h>
class base
public:
______f( )return 0;
;
class derived:public base
public:
int a,b,c;
______set(int x,int y,int z)a=x;b=y;c=z;
int f( )return a+b+c;
;
void main( )
base b;
derived d;
cout<<b.f( )<<",";
d.set(3,5,7);
cout<<d.f( )<<",";
base &p=d;
cout<<p.f( )<<endl;