更多"设文件temp.txt 已存在,则以下的打印结果是 【15】 #i"的相关试题:
[填空题]设文件temp.txt 已存在,则以下的打印结果是 【15】
#include <iostream>
#include <fstream>
using namespace std;
int main( )
ofstream outf ("temp.txt",ios base: :trunC) ;
outf<<"How you doing";
outf.close( );
ifstream inf("temp.txt");
char str[20];
inf>>str;
inf.close( );
cout<<str;
return 0;
[填空题]main函数中发生编译错误的语句是 【12】 。
# include <iostream. h>
class A
{
public:
int a;
const int b:
A( ) :a(10) ,b(20) {
void fun( ) const
{
cout<<"a="<<a<<"/tb="<<b<<end1;
}
};
void main( )
A obj1;
const A * ptr = new A:
ptr = &obj1;
ptr->a=lO0;
ptr->fun( ),
}
[单项选择]要使程序执行后的输出结果为ABCD,应在横线处添加语句( )。
#include<iostream>
using namespace std;
public:A( )cout<<’A’;
;
class B=______
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;
A. public A
B. private A
C. protected A
D. virtual public A
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。
#include<iostream.h)
#include(string.h>
template(class T)
T min(T a,T b)
{
return(a<ba:b);
}
char*min(char*a,char*b)
{
}
void main( )
{
double a=1.23,b=3.45;
chars1[]=”abcd”,s2[]=”efg”;
cout<<min(a,b)<<rain(s1,s2)<(endl;
}
[填空题]下列程序不能通过编译,应该在划线部分填写的语句是______。
#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;
}
[填空题]下列类的构造函数不能通过编译,正确的构造函数应该是______。
#include<iostream.h>
class Sample
public:
int n;
const int con;
Sample(int m) con=m+1;n=m;
void disp( ) cout<<"normal:n="<<n<<endl;
void disp( )const cout<<"static:n="<<n<<endl;
;
void main( )
const Sample a (12);
Sample b (13);
a.disp( );
b.isp( );
cout<<a.n<<","<<b.con<<endl;
[填空题]执行以下程序,输入-10的结果是 【14】 ,输入5的结果是 【15】 ,输入10的结果是
【16】 ,输入30的结果是 【17】 。
# include<stdio.h> main( ) int x,c,m; float y; scanf("%d",&x); if(x<0)c=-1 else c=x/10; switch(c) case-1;y=0;break; case0;y=x;break; case1;y=10;break case2: case3;y=-0.5 * x + 20;break; default:y=-2; if(y!=-2)printf("y=%f"/n",y); else printf("error/n");
[填空题]下面程序的打印结果是 【11】 。
#include <iostream>
using namespace std;
class Base
public:
Base(int x)
a=x;
void show( )
cout<<a;
private:
int a;
;
class Derived : public Base
public:
Derived(int i) :Base(i+1) ,b(i)
void show( )
cout<<b;
private:
int b;
;
int main ( )
Base b(5) , *pb;
Derived d(1);
pb=&d;
pb->show( );
return 0;
[单项选择]在PowerPoint中,设置每张纸打印三张讲义,打印的结果是幻灯片按______的方式排列。
A. 从左到右顺序放置三张讲义
B. 从上到下顺序放置在居中
C. 从上到下顺序放置在左侧,右侧为使用者留下适当的注释空间
D. 从上到下顺序放置在右侧,左侧为使用者留下适当的注释空间
[填空题]下面程序的打印结果是 【11】 。
#include <iostream>
using namespace std;
class Base
{
public:
Base(int x)
{
a=x;
}
void show( )
{
cout<<a;
}
private:
int a;
};
class Derived : public Base
{
public:
Derived(int i) :Base(i+1) ,b(i) { }
void show( )
{
cout<<b;
}
private:
int b;
};
int main ( )
{
Base b(5) , *pb;
Derived d(1);
pb=&d;
pb->show( );
return 0;
}
[填空题]下面程序的打印结果是______。
#include <iostream>
using namespace std;
class Base
public:
Base(int x)
a=x;
void show( )
cout<<a;
private:
int a;
;
class Derived : public Base
public:
Derived(int i) :Base(i+1) ,b(i)
void show( )
cout<<b;
private:
int b;
;
int main ( )
Base b(5) , *pb;
Derived d(1);
pb=&d;
pb->show( );
return 0;
[单项选择]以下事件过程的功能是:从已存在于磁盘上的顺序文件Num1.txt中读取数据,计算读出数据的平方值,将该数据及其平方值存入新的顺序文件Num2.txt中。则在以下横线处合适的语句是( )。
Private Sub Form_Click( )
Dim x As Single,y As Single
Open "Num1.txt" For Input As #1
Open "Num2.txt" For Output As #2
Do While Not EOF(1)
______
Print x
y=x^2
Print y
Loop
Close #1,#2
End Sub
A. Input #1,y Print#2,x,y
B. Input #2,x Print #1,x,y
C. Print #1,x Input#2,x,y
D. Input #1,x Print #2,x,y
[单项选择]以下哪种对象得到的输出结果是适当的( )。
A. 财务部门得到进货计划
B. 销售班组得到库存统计
C. 储运部门得到日销售统计
D. 决策层得到业绩分析报告
[填空题]下列程序运行后,在窗体上打印的结果是 【14】 。
Private Sub test(a, b,c)
a = a + 1: b = b + 2:C = C + 3
End Sub
Private Sub Command1 Click( )
x = 1:v = 2:z = 3
Call test(x,y + 3, (z))
Print "Main:";x;y;z
End Sub
[填空题]下列程序运行后,在窗体上打印的结果是 【14】 。
Private Sub test(a, b,c)
a = a + 1: b = b + 2:C = C + 3
End Sub
Private Sub Command1 Click( )
x = 1:v = 2:z = 3
Call test(x,y + 3, (z))
Print "Main:";x;y;z
End Sub
[填空题]以下程序的执行结果是 。
#include<iostream. h>
class Sample
{
public:
int x:
int y;
void disp( )
{
cout<<"x="<<x<<",y="<<y<<end1;
}
};
void main( )
{
int Sample:: ** pc;
Sample s;
pc=& Sample: :x;
s.*pc=10;
pc:=&Sample: :y;
s.*pc=20;
s.disp( );
}