以下程序的执行结果是_______。
include<iostream.h>
include<fstream.h>
include<stdlib.h>
void main()
{
char ch:
fstream file:
file.open("abc.dat",ios::out1ios::inlios::binary);
if(! file)
{
cout<<“abc.dat文件不能打开”<<endl:
abort
第1题:
以下程序的执行结果是【 】。
include<iostream.h>
include<stdlib.h>
class Sample
{
public:
int x,y;
Sample(){x=y=0;}
Sample(int a,int b) {x=a;y=b; }
void disp()
{
cout<<"x="<<x<<",y="<<y<<end1;
}
};
void main() {
Sample s1(2,3);
s1.disp();
}
第2题:
以下程序的执行结果是【 】。
include <iostream.h>
include <fstream.h>
include <stdlib.h>
int main()
{
fstream outfile, infile;
outfile.open("D:\\text.dat",ios::out);
if(!outfile)
{
cout<<"text.dat can't open"<<end1
第3题:
下列程序的执行结果是( )。 #include<iostream.h> #include<stdlib.h> class TestClass { public: intx,y; TestClass(){x=y=0;} TestClass(int a,int b){x=a;y=b;} void disp() { cout<<"X"="<<X<<",y="<<y<<endl; }
A.x=2,y=2
B.x=3,y=3
C.x=2,y=3
D.x=3,y=2
第4题:
以下程序的执行结果是______
include<iostream.h>
include<iomanip.h>
void print(int n)
{
if(n!=0)
{
print(n-1);
for(int i=1;i<=n;i++=
cout<<setw(3)<<i;
cout<<endl;
}
}
void main()
{
print (4);
}
第5题:
下列程序的输出结果是______。
include <iostream.h>
include <cstring.h>
using namespace std;
void fun(const char*s,char &C) {c=s[strlen (s)/2];}
int main {)
{
char str [] ="ABCDE";
char ch=str[1];
fun(str,sh);
cout<<Ch;
return 0;
}