更多"下列程序的输出结果是______。
#include <iost"的相关试题:
[填空题]以下程序执行后输出的结果是 【15】 。
#include<iostream>
#include<fstream>
using namespace std;
int main( ){
ofstream ofile("D://temp.txt");
if(!ofile){
cout<<"temp.txt cannot open"<<endl;
return 0;
}
ofile<<"This is a book" <<" " <<54321<<endl;
ofile.close( );
ifstream ifile("D://temp.txt");
if(!ifile){
cout<<"temp.txt cannot open" <<endl;
return 0;
}
charstr[40];
ifile >> str;
ifile.close( );
cout<<Str<<endl;
return 1;
}
[填空题]以下程序的执行结果是 【15】 。
#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;
abort( );
}
outfile<<"1234567890"<<end1;
outfile<<"abcdefghij"<<end1;
outfile.close( );
infile.open("D:/text.dat",ios::in);
if(!infile)
{
cout<<"text.dat can’t open"<<end1;
abort ( );
}
char textline[40];
int i=0;
while(!infile.eof( ))
{
i++;
infile.getline(textline,sizeof(textline));
cout<<i<<":"<<textline<<end1;
}
infile.close( );
return 0;
}
[单项选择]如下程序的输出结果是 #include<iostream> #include<iomanip> using namespace std; class CSum{ int x,y; public: CSum(int x0,int y0):X(x0),y(y0){ } friend ostream& operator<<(ostream& os,const CSum& xA) { os<<setw(5)<<xa.x+xa.y: return os; } }; int main( ){ CSum y(3,5); cout<<setfill(’*’)<<8; cout<<y; return 0; }
A. 88
B. ****88
C. ****8****8
D. 8****8
[单项选择]如下程序的输出结果是 #include<iostream> #include<cstring> using namespace std; class XCF{ int a; public: XCF(int aa=0):a(aA) {cout<<"1";} XCF(XCF&X){a=x.a;cout<<"2";l ~XCF( ){cout<<a;} int Geta( )t return a;} }; int main( ){ XCF d(15),d2(d1); XCF*pd=new XCF(8); cout<<pd->Geta( ); delete pd; return 0; }
A. 1215588
B. 1218855
C. 12185
D. 128512
[填空题]下列程序的输出结果是 【9】 。
#include<iostream>
#include<cstring>
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, ch);
cout<<ch;
return 0;
[填空题]下列程序输出结果是 【13】 。
include <iostream>
using namespace std;
template <typename T>
T fun(T a, T b) return (a<=b)a:b;
int main( )
cout<<fun(3,6)<<’,’<<fim(3.14F, 6.28F)<<end 1;
return 0;
[填空题]以下程序的执行结果是_______。
#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( );
}
file<<“12 34 56”<<endl:
file.seekg(o,ios::beg):
while(!file.eof( ))
{
streampos here=file.tellg( );
file.get(ch):
if(ch==’’)
cout<<here<<"":
}
cout<<endl:
}
[单项选择]以下程序的输出结果是( )。
#include<iostream>
#include<stdlib>
using namespace std;
void func(char **m)
++m;
cout<<*m<<endl;
main( )
static char *a[]="MORNING","AFTERNOON","EVENING");
char **n;
n=a;
func(n);
system("PAUSE");
return 0;
A. 为空
B. MORNING
C. AFTERNOON
D. EVENING
[单项选择]下面程序的输出结果是( )。
#include<iostream>
#include<math.h>
using namespace std;
class point
private:
double x;
double y;
public:
point(double a,double b)
x=a;
y=b;
friend double distances(point a,point b);
;
double distances(point a,point b)
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
int main( )
point p1(1,2);
point p2(5,2);
cout<<distances(p1,p2)<<end1;
return 0;
A. 2
B. 4
C. 8
D. 16
[单项选择]下面程序的输出结果是( )。 #include<iostream> #include<string> using namespace std; void main( ){ charp1[10],p2[10]; strcpy(p1,"abc"); strcpy(p2,"ABC"); charstr[50]="xyz"; strcpy(str+2,strcat(p1,p2)); cout<<str; }
A. xyabcABC
B. yzabcABC
C. xyzabcABC
D. zabcABC
[填空题]以下程序的输出结果是 [9] 。
include<iostream.h>
include <string.h>
void main 0
char s[50];
strcpy(&s[O], "No" );
strcpy(&s[1], "123" );
strcpy (&s[2], "23456" );
cout<<s;