设有char *s="ABCDE";cout<< (s+1)<< endl;输出结果是()
第1题:
有以下程序 main() { char s[]="ABCD",*p; for(p=s+1;p<s+4;p++)printf("%s\n",p); } 程序运行后的输出结果是
A.ABCD BCD CD D
B.A B C D
C.B C D
D.BCD CD D
第2题:
下列程序时类D代码段出现编译错误,原因是【 】。
include<iostream. h>
class A
{
public:
A(char c){cout<<"A's constructor."<<c<<endl;}
~A(){cout<<"A's destructor."<<endl;}
};
class B: virtual public A
{
public:
B(char cb,char cd):A(cb) {cout<<"B's constructor."<<cd<<endl;}
~B(){cout<<"B's destructor."<<endl;}
private:
char b;
};
class C:virtual public A
{
public:
C(char cc, char cd):A(cc)
{cout<<"C's constructor. "<<cd<<endl;}
~C(){cout<<"C's destructor."<<endl;}
};
class D:public B,public C
{
public:
D(char cd,char ce,char cf, char cg, char ch,char ci)
:C(cf,cg),B(cd,ce),A(cd),aa(ch)
{cout<<"D's constructor."<<ci<<endl;}
~D() {cout<<"D's destructor."<<endl;}
private:
A aa;
};
void main()
{
D ohj('a','b','c','d','e','f')
}
第3题:
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
[说明]
本程序使用类来管理员工的通讯地址信息。已知程序的输出为:
输出记录:5
姓名:王丽华
街道地址:中华路15号
市:襄樊市
省;湖北省
邮政编码:430070
[C++程序]
include < iostream, h >
include < string, h >
class employee.
{ protected:
char name[10];
char street[ 20 ];
char city[10];
char (1) [10];
char post[7];
int no;
(2):
(3) (char [] ,char [] ,char [] ,char [] ,char [] ,int);
void changename ( char n [] ) { strcpy ( name, n); }
void changestreet( char s[] ) { strcpy(street,s) ;}
void changecity ( char c [] ) { strcpy ( city, c ); }
void changeprov( char p [] ) { strcpy(prov,p); }
void changeno(int nnm) { (4);}
void display( );
};
employee:: (3) (char n[] ,char s[] ,char c[] ,char p1[] ,char p2[] ,int nam)
{ strcpy(name,n);
strcpy ( street, s);
strcpy ( city, c);
strcpy ( prov, p1 );
strcpy ( post, p2 );
no = nam; }
void employee:: display( ) { cont< <"输出记录: "< <no< <endl;
cout< < "姓名: "< < name < < endl;
coot < < "街道地址: "< < street < < endl;
cout < < "市: "< < city < < endl;
cout< <"省: "< <prov < <endl;
cout < <"邮政编码: "< < post < < endl;
}
void main( ) { employee cmp("王华" ,"中华路15号" ,"武汉市","湖北省","430070", 1 );
emp. changename( "五丽华" );
emp. changecity ( "襄樊市" );
emp. changeno(5);
(5);
第4题:
请将下面的程序补充完整,使得程序输出“飘是张娜的书”。
include
using namespace std
class Book{
public:
Book(char*str)|strcpy(title,str);
______void Printlnfo(){cout<<title<<endl;}
protected:
char title[50];
};
class MyBook:public Book{
public:
MyBook(char*s1,char*S2=“张娜”):
______strcpy(owner,s2);}
virtual void PrintInfo(){cout<<title<<“是”<<owner<<“的书”<<endl;}
private:
charowner[10];
};
int main(){
Book*ptr=new MyBook(“飘”);
ptr->Printlnfo();
return 0;
}
第5题:
下面程序段的运行结果是 #include<iostream.h> void main( ) { char*s="abcde"; S+=2; cout<<&s;}
A.cde
B.字符'c'
C.字符'c'的地址
D.无确定的输出结果
第6题:
以下程序的输出结果是( )。 #include<iostream.h> int fun (char*s) { char *p=s; while (*p!='\0,) p++: return (p-s): } void main() { cout<<fun (" ABCDEF ")<<endl: }
A.3
B.6
C.8
D.0
第7题:
设有定义:char s[12]={"hello"},则cout<<strlen(s)的输出是 ______。
A.5
B.6
C.11
D.12
第8题:
以下三条输出语句分别输出什么?
char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << boolalpha << ( str1==str2 ) << endl; // 输出什么?
cout << boolalpha << ( str3==str4 ) << endl; // 输出什么?
cout << boolalpha << ( str5==str6 ) << endl; // 输出什么?
第9题:
以下程序的输出结果是【 】。
char s[ ]="XYZQ";
void main(){
char *p;
for(p = s; p < s+4; p++)
cout<<p<<end1;
}
第10题:
下列程序执行后的输出结果是 #include<string.h> main() { char arr[2][4]; strcpy(arr, "you"); strcpy(arr[1], "me"); arr[0][3]='&'; cout<<arr<<endl; }
A.you&me
B.you
C.me
D.err
第11题:
设有char *s="ABCDE";cout<< strlen(s)<< endl;输出结果是()
第12题:
A
B
ABCD
BCD
第13题:
连续执行以下命令之后,最后一条命令的输出结果是 ______。 SET EXACT OFF X="A" ?IIF("A"=X,X-"BCD",X+"BCD")
A.A
B.BCD
C.ABCD
D.ABCD
第14题:
请编写一个函数char*change(char instr[]),将输入字符串中的所有小写字母转换为大写字母输出。要求使用for循环实现。如输入jinfeiteng,则输出结果是JINFEITENG。
注意:部分源程序已存在文件test21_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数change的花括号中填写若干语句。
文件test21_2.cpp的内容如下:
char*change(char instr[]);
include"iostream.h"
void main()
{
char instr[50];
char *outstr;
cout<<"Input a string:"<<endl;
cin>>instr;
utstr=change(instr);
cout<<"Over graded string:"<<endl;
cout<<outstr<<endl;
}
char*change(char instr[])
{
}
第15题:
下面程序运行输出的结果是【 】。
include <iostream>
using namespace std;
int main(){
char a[]="Chinese";
a[3]='\0';
cout<<a<<endl;
return 0;
}
第16题:
以下程序的输出结果是( )。 #include<iostream.h> void func(char**m) { ++m: cout<<*m<<endl; } void main() { static char*a[]={"MORNING","AFTERTOON","EVENING"}; char**n; n=a: func(n); }
A.为空
B.MORNING
C.AFTERTOON
D.EVENING
第17题:
以下程序的输出结果是( )。 #include<iostream> using namespace std; void fun(char**q) { ++q; cout<<*q<<end1; } main() { static char*s[]={"HI","HELL0","TEST"}; char**p; p=s; fun(p); system("PAUSE"); return 0; }
A.为空
B.HI
C.HELL0
D.TEST
第18题:
下面程序的输出结果是( )。 #include<iostream.h> #include"stdng.h" void main() { char a[]="welcome",b[]="well"; strcpy(a,b); cout<<a<<endl; }
A.wellome
B.wellcom
C.well
D.wellwe
第19题:
以下程序的输出结果是( )。 #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
第20题:
连续执行以下命令之后,最后一条命令的输出结果是( )。

A)A
B)BCD
C)ABCD
D)A BCD
第21题:
连续执行以下命令之合,最后一条命令的输出结果是______。SETEXACTOFFX=“A”?HF(“A”;X,X-“BCD”,X+“BCD”)
A.A
B.BCD
C.ABCD
D.ABCD
第22题:
下列程序段的输出结果是_____。
cout < < fixed < < 509.123456789 < < endl;
第23题:
6
5
4
1