更多"要使程序执行后的输出结果为ABCD,应在横线处添加语句( )。 #"的相关试题:
[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。
#include <iostream>
using namespace std;
class A
{
public: A( ) {cout<<’A’;}
};
class B: 【11】
{
public:B( ) {cout<<’B’;}
};
class C: 【12】
{
public: C( ){cout<<’C’;}
};
class D:public B,public C
{
public:D( ) {cout<<’D’;}
};
void main( ) {D obj; }
[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。
#include <iostream>
using namespace std;
class A
public: A( ) {cout<<’A’; }
};
class B: 【14】
public: B( ){cout<<’B’;}
class C: virtual public A
public: C( ){cout<<’C’;}
class D:public B, public C
public: D( ) { cout<<’D’; }
};
void main( ) { D obj; }
[填空题]在下面程序的横线处填上适当的语句,使程序执行后的输出结果为ABCD。
#include<iostream>
using namespace std;
classA
public:
A( )cout<<’A’;
;
class B:______
public:
B( )cout<<’B’;
;
class C:______
public:C( )cout<<’C’;
;
class D:public B,public C
public:D( )cout<<’D’;
;
void main( )D obj;)
[单项选择]在下列程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。 #include<iostream> using namespace std; class A { public:A( ){cout<<‘A’;} }; Class B: { public:B( ){cout<<‘B’;} }; class C://virtual public A { public:C( ){cout<<‘C’;} }; class D://public B,public D { public:D( ){tout<<‘D’;} }; void main( ){D obj;}
A. public A
B. private A
C. protected A
D. virtual public A
[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。
#include<iostream.h>
using namespace std;
class A
public:A( )cout<<’A’;
;
class B:______
public:B( )cout<<’B’;
;
class C://______
public:C( )cout<<’C’;
;
class D://public B,public C
public:D( )cout<<’D’;
;
void main( )D obj;
[填空题]在下向程序和横线处填上适当的内容,使程序执行后的输出结果为1/2005。
#include <iostream>
using namespace std;
class Date
{
public:
Date(int m=1,int y=0):month(m),year(y){}
void Print( ) {cout<<month<<"/"<<year<<end 1; }
【9】 operator+(eonst Date& d1, const Date& d2);
private:
int month,year;
};
【10】 operator+(const Date& d1, const Date& d2)
{
int year,month;
year=d1 .year+d2.year;
month=d1. month+d2.month;
year+=(month-1 )/12;
month=(month-1 )% 12+1;
return Date(month,year);
}
void main( )
Date d1 (3,2004),d2,d3(10);
d2=d3+d1;
d2,Print( );
}
[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果果为1/2005。
#include<iostmam>
using namespace std;
class Date
public:
Date(int m=1,int y=0):month(m),year(y)
void Print( )cout<<month<<"/"<<year<<endl;
operator+(const Date&d1.const Date& d2);
private:
int month,year;
;
operator+(const Date&d1,const Date &d2)
int year,month;
year=d1.year+d2.year;
month=d1.month+d2.month;
year+=(month-1)/12;
month=(month-1)%12+1;
return Date(month,year);
void main( )
Date d1(3,2004),d2,d3(10);
d2=d3+d1;
d2.Print( );
[填空题]在下面程序的横线处填上______,使程序执行后的输出结果为1/2005。
#include<iostream.h>
using namespace std;
class Date
Public:
Date(int m=1,int y=0): month(m),year(y)
void Print( )cout<<month<<"/"<<year<<end1;
______operator+(const Date&d1,const Date&d2);
private:
int month, year;
;
Date operator+(const Date&d1,const Date&d2)
int year,month;
year=d1.year+d2.year;
month=d1.month+d2.month;
year+=(month-1)/12;
month=(month-1)%12+1;
return Date(month,year);
void main( )
Date d1(3,2004),d2,d3(10);
d2=d3+d1;
d2.Print( );
[填空题]下列程序不能通过编译,应该在划线部分填写的语句是______。
#include<iostream.h>
#include<stdlib.h>
double Func(int a,int b,char ch)
{
double x;
switch(ch)
{
case’+’:
x=double(a)+b;
break;
case ’-’:
x=double(a)-b;
break;
case ’*’:
x=double(a)*b;
break;
case’/’:
if(B)x=double(a)/b;
else
exit(1);
break;
default:
exit(1);
}
______
}
void main( )
{
cout<<Func(32,6,’-’)<<",";
cout<<Func(32,6, ’*’)<<",";
cout<<Func(32,6,’/’)<<endl;
}
[填空题]请将下列程序的横线处补充完整,使得输出结果为bbaa
#include<iostream>
using namespace std;
class A{
public:
______{cout<<"aa";}
};
class B:public A{
public:
~B( ){cout<<"bb";}
};
int main( ){
B*p=new B;
delete p;
retum 0;
}
[单项选择]选择正确的语句填在下列程序的横线处,使程序正常运行。 package ch1; import java. io. *; import j ava. util. *; class C45 implements Seritizable ______Public Thread t = new Thread(new T45( ), "t"); public intcnt = 0; public C45( ) { t. start ( ) class T45 implements Runnable public int[] a = new int[4]; public void run( ) { for(int i - 0; i < 4; i++) { a[i] - i +4; } } } public class ex45 { static String fileName = "ch1//file45.txt"; public static void main(String[] args) throws Exception { C45 obj = new C45 ( ); FileOutputStream fos = new FileOutputStream(fileName); ObjectOutputStream oos = new ObjectOutputStream(fos); oos. writeObject (obj); oos.clese ( ); fos.close ( ); System. out, println (obj . toString ( ) ); } }
A. transient
B. protected
C. package
D. final
[填空题]在下面程序横线处填上适当内容,使得程序的输出为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;
}
[简答题]请在下面程序中的每条横线处填写一个语句,使程序的功能完整。程序的输出结果为:
TIME=1867
b=9
i=123
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
import java.io.*;
public class DataType{
public______________void main(String args[])
{
byte b;
int i;//定义变量i为int类型
___________________________ //定义常量TIME为整型,且值为1867
i=123;//给变量i赋值,该值为十进制的123
__________________________________//给变量赋值,改值为,八进制的11,十进制的9
System.out.println("TIME”+TIME);
System.out.println("b="+b);
System.out.println("i="+i);
}
}
[简答题]请在下面程序中的每条横线处填写一个语句,使程序的功能完整。程序的输出结果为:
TIME=1867
b=9
i=123
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
源程序文件代码清单如下:
import java.io.*;
public class DataType
{
public ______ void main(String args[])
{
byte b;
int i;//定义变量i为int类型
______//定义常量TIME为整型,且值为1867
i=123;//给变量i赋值,该值为十进制的123
______//给变量赋值,改值为八进制的11,十进制的9
System.out.println("TIME"+TIME);
System.out.println("b="+b);
System.out.println("i="+i);
}
}