四、完成程序題(本大題共5小題,每小題4分,共20分)
46.將下面程序補充完整,使程序輸出結(jié)果為:
Begin
Welcome
Show
End
程序如下:
#include
using namespace std;
class A{
public:
__________{
cout <<″Begin″<
void show( ){
cout<<″Show″<
___________{
cout<<″End″<
};
A object;
int main( ){
cout <<″Welcome″<
return 0;
}
47.請將下面程序補充完整,使程序可以正常打印9×9乘法口訣。
#include
using namespace std;
class A {
private:
int a;int b;
public:
__________
{ a = x;b = y; }
void set(int x,int y)
{ a = x;b = y; }
void display( ){
cout<}
};
int main( ){
A a(1,1);
for(int i=1;i<=9;i++){
for(int j=1;____;j++){
a.set(j,i);
a.display( );
cout<<″″;
}
cout<
return 0;
}