有以下程序: #include <iostream> using namespace std; int main ( ) { char s1[10],s2[10]; char *p=s1,*q=s2; cin>>s1>>s2; while (*p ! =' \0 ' ) p++; while (*q!='\0') *p++=*q++; *p='\0'; cout<<s1<<end1; return 0; }
A.abcd0ghij
B.abcd0ghij0
C.abcd
D.abcdghij
第1题:
下列程序的输出结果是( )。 #include<iostream> using namespace std; int main() 于 chara[]=”Hello,Test”; Char*p=a; while(*p) { if(*p)=’a’&&*p(=’z’) cout<<char(*p+’A’-’a’); else cout<<*p; p++; } return 0; }
A.hello,test
B.Hello,Test
C.HELLO,TEST
D.hELLO,tEST
第2题:
有以下程序:
include <iostream>
using namespace std;
int main()
{
int i=010,j=10;
cout<<(++i)<<","<<i--<<end1;
return 0;
}
则该程序运行后的输出结果是【 】。
第3题:
有以下程序: #include <iostream> using namespace std; char *x[]={"First", "Second", "Third" }; void f(char *z[ ]) { cout<<*z++<<end1; } int main ( ) { char **y; y=x; f(y); return 0; }
A.产生语法错误
B.First
C.Secpnd
D.Third
第4题:
下列程序的输出结果是( )。 #include<iostream> using namespace std; int main() { char a[]="Hello,Test"; char *p=a; while(*p) { if(*p>='a'&&*p<='z') cout<<char(*p+'A'-'a'); else cout<<*p; p++; } return 0; }
A.hello,test
B.Hello,Test
C.HELLO,TEST
D.hELLO,tEST
第5题:
若有如下程序: #include <iostream> using namespace std; int main() { char *p="abcdefgh",*r; long *q; q=(long *)p; q++; r=(char *)q; cout<<r<<end1; return 0; } 上述程序的输出结果是( )。
A.abcdefgh
B.0
C.abcd
D.efgh
第6题:
有以下程序,其输出结果是( )。 #include <iostream> using namespace std; int main(){ char a[10]={'1','2','3','4','5','6','7','8','9',0},*p; int i=8; p=a+i; cout<<p-3<<endl; return 0; }
A.6789
B.6
C.789
D.'6'
第7题:
有以下程序:
include <fstream>
include <string>
using namespace std;
int main ()
{
char ch[] = "The end";
ofstream outstr( "d:\\put.txt", ios_base: :app);
for (int i = 0; i < strlen( ch ); i++ )
outstr.put(ch[i]);
outstr.close();
return 0;
}
程序实现的功能是【 】。
第8题:
下列程序的输出结果是( )。 #include<iostream> using namespace std; int main() { char a[]="Hello,Test"; char *p=a; while(*p) { if(*p>='a'&&*p<='’z') cout<<char(*p+'A'-'a'); else cout<<*p; p++; } return 0; }
A.hello,test
B.Hello,Test
C.HELLO,TEST
D.hELLO,tEST
第9题:
有以下程序: #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.#
第10题:
有以下程序: #include<iostream> #include<string> using namespace std; int main() { char arr[2][4]; strcpy(arr[0],"you"); strcpy(arr[1],"me"); arr[0][3]='&'; cout<<arr[0]<<end1; return 0; } 执行后的输出结果是( )。
A.you&me
B.you
C.me
D.err
第11题:
有下列程序段: #include <iostream> using namespace std; int main() { char b[] = "Hello,you"; b[5] = 0; cout<<b<<end1; return 0; } 执行此程序后,得到的输出结果是( )。
A.Hello,you
B.Hello0you
C.Hello
D.0
第12题:
有以下程序: #include<iostream> using namespace std; int main() { char a[10] = {'1','2','3','4','5','6','7','8','9','0'),*p; int i=8; p=a+i; cout<<p-3<<end1; return 0; } 执行程序后的输出结果是( )。
A.6
B.6789
C.'6'
D.789
第13题:
有如下程序: #include <iostream> using namespace std; int main() { char str[100], *p; cout<<"Please input a string:"; cin>>str; p=str; for (int i=0; *p!='\0'; p++,i++); cout<<i<<endl; return 0; }运行这个程序时,若输入字符串为 abcdefgabcd则输出结果是
A.7
B.12
C.13
D.100
第14题:
下面程序运行输出的结果是【 】。
include <iostream>
using namespace std;
int main(){
char a[]="Chinese";
a[3]='\0';
cout<<a<<endl;
return 0;
}
第15题:
有以下程序 #include<iostream> #include<string> using namespace std; class base { private: charbaseName[10]; public: base() { strcpy(baseName,"Base"); } virtual char*myName() return baseName; } char *className() { return baseName; } }; class Derived: public base { private: char derivedName[10]; public: Derived() { strcpy(derivedName,"Derived"); } char *myName() { return derivedName; } char *className() { return derivedName; } }; void showPtr(base &p) { cout<<p.myName0<<" "<<p.className(); } int main() { base bb; Derived dd; showPtr(dD) ; retum 0; } 动行后的输出结果为
A.Derived Base
B.Base Base
C.Derived Derived
D.Base Derived
第16题:
有以下程序 #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base () { strcpy(baseName,"Base"); } virtual char *myName() { return baseName; } char *className() { return baseName; } }; class Derived : public base { private: char derivedName[10]; public: Derived() { strcpy(derivedName,"Derived"); } char *myName() { return derivedName; } char *className() { return derivedName; } }; void showPtr(base &p) { cout<<p.myName () <<" "<<p.className (); } int main () { base bb; Derived dd; showPtr(dd); return 0; } 运行后的输出结果为
A.Derived Base
B.Base Base
C.Derived Derived
D.Base Derived
第17题:
若有如下程序段:
include <iostream>
using namespace std;
int main()
{
char *p="abcdefgh",*r;
long *q;
q=(long *)p;q++;
r=(char *)q;
cout<<r<<end1;
return 0;
}
该程序的输出结果是______。
第18题:
若有以下程序:
include <iostream>
using namespace std;
int main()
{
char str[10];
cin>>str;
cout<< str<<end1;
return 0;
}
当输入为:
This is a program!
那么执行程序后的输出结果是【 】。
第19题:
下列程序的输出结果是______。
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;
}
第20题:
有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, "Base"); } virtual char *myName() {
A.DerivedBase
B.BaseBase
C.DerivedDerived
D.BaseDerived
第21题:
以下程序的执行结果为【 】。
include<iostream>
using namespace std;
void overload(int num)
{
cout<<num<<end1;
}
void overload(char ch)
{
char c=ch+1;
cout<<c<<end1;
}
int main()
{
overload('X');
return 0;
}
第22题:
有以下程序: #include <iostream> #include <string> using namespace std; int main ( ) { char b1[8] = "abcdefg"; char b2[8],*pb=b1+3; while (--pb>=b1) strcpy (b2, Pb) ; cout<<strlen (b2) <<end1; return 0; } 程序运行后的输出结果是( )。
A.8
B.3
C.1
D.7
第23题:
有以下程序: #include <iostream> #include <string> usxng namespace std; int main() { char p[] = "abcdefgh"; cout<<strlen(strcpy(p,"12345"))<<end1; return 0; } 执行后输出的结果是( )。
A.8
B.12
C.5
D.7