有如下的程序:
include<iostream>
include<fstream>
using namespace std;
int main(){
char s[25]="Programming language";
ofstream f1("DATA. TXT");
f1<<"C++Programming";
f1.close();
ifstream f2("DATA.TXT");
if(f2.good())f2>>s;
f2.close();
cout<<s;
return 0;
}
执行上面的程序将输出______。
第1题:
有如下的程序:
include <iostream>
include <fstream>
using namespace std;
int main()
{
ofstream outf("D:\\temp.txt",ios_base::trunc) ;
outf<<"World Wide Web";
outf.close();
ifstream inf("D:\\temp.txt");
char s[20];
inf>>s;
inf.close();
cout<<s;
return 0;
}
执行后的输出结果是【 】。
第2题:
有以下程序 #include <stdio.h> #include <string.h> void fun(char *s[],int n) { char *t; int i,j; for(i=0;i<n-1;++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])) {t=s[i];s[i];s[j];s[j]=t;} } main() { char *ss[]={"bcc
A.xy,aaaacc
B.aaaacc,xy
C.bcc,aabcc
D.aabcc,bcc
第3题:
有以下程序: #include <stdio.h>#include <string.h>void f(char * s,char*t){ char k; k=*s; *s=*t; *t=k; s++; t--; if( * s) f(s,t);}main( ){ char str[10] :"abedefg", * p; p = str + strlen(str)/2+1; f(p,p -2); printf( "% s \n" ,str);程序运行后的输出结果是( )。
A.abcdefg
B.gfedcba
C.gbcdefa
D.abedcfg
第4题:
如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }
A.42,42
B.23,23
C.23,42
D.42,23
第5题:
有以下程序: #include <iostream> #include <fstream> using namespace std; int main ( ) { ofstream ofile; char ch; ofile.open ("abc.txt"); cin>>ch; while (ch!='#' ) { cin>>ch; ofile.put(ch);
A.程序编译时出错
B.abc#
C.abc
D.#