“CHAR(N)”表示()。
第1题:
有以下定义语句,编译时会出现编译错误的是
A)char a='a';
B)char a='\n';
C)char a='aa';
D)char a='\x2d';
第2题:
有以下程序:
include <iostream>
using namespace std;
const xnt N=5;
int fun(char *s,char a,int n)
{
int j;
*s=a;j=n;
while(a<s[j])
j--;
return j;
}
int main()
{
char s[N+1];
int k;
第3题:
A. char (*w)[N]
B. char *w[N]
C. char (*w)N
D. char**a
正确答案:B
第4题:
以下程序的输出结果是( )。 #include<iostream.h> void func(char**m) { ++m: cout<<*m<<end1; } void main() { static char*a[]={"MORNING","AFTERTOON","EVENING"}; char**n: n=a; func(n); }
A.为空
B.MORNING
C.AFTERTOON
D.EVENING
第5题:
请编写一个函数char *fun(char *s,int n)。函数fun()的功能是将字符串s中的字符“循环左移”n位。例如,输入“ABCDE”,则循环左移2位应输出“CDEAB”,输入“1234567”,循环左移3位应输出“4567123”。
注意:部分源程序已存在文件PROC13.cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句。
文件PROC13.cpp的内容如下:
//PROC13.cpp
include <iostream>
include <string>
using namespace std;
char *fun(char *s,int n);
int main()
{
char str[81];
int n;
cout<<"Enter a string(less than 80 char)\n”;
cin>>str;
cout<<"\n Enter n:";
cin>>n;
if(n>strlen(str))
{
cout<<"\n Data overflow";
return 0;
}
cout<<"The result is: "<<fun(str,n)<<end1;
return 0;
}
char *fun(char*s,int n)
{
//* * * * * *
}
第6题:
有以下程序: #include<stdio.h> void fun(char**p) { ++P;printf("%s\n",*p);} main() char*a[]={"Morning","Afternoon","Evening","Night"}; fun(A); } 程序的运行结果是( )。
A.Afternoon
B.fternoon
C.Morning
D.oring
第7题:
有如下程序: #include<iostream> using namespace std; class Base { private: char c; piblic: Base(char n):c(n){} ~Base() { cout<<C; } }; class DeriVed:public Base { private: char c; public: Derived(char n):Base(n+1),c(n){} ~Derived() { cout<<c; } }; int main() { Derived obj('x'); return 0; } 执行上面的程序将输出
A.xy
B.yx
C.x
D.y
第8题:
以下结构体类型说明和变量定义中正确的是
A)typedef struct
{int n; char c;} REC;
REC t1,t2;
B)struct REC;
{int n; char c;};
REC t1,t2;
C)typedef struct REC ;
{int n=0; char c='A';} t1,t2
D)struct
{int n;char c;}REC;
REC t1,t2;
第9题:
有以下程序 #include <stdio.h> int fun(char s[]) { int n=O; while(*s<='9'&&*s>='0') { n=10*n+*s-'0'; s++; } return (n); } main() { char s[10]={ '6', '1', '*', '4', '*', '9', '*', '0', '*'}; printf("%d\n",fun(s)); }
A.9
B.61490
C.61
D.5
第10题:
有如下程序: #include<iostream> using namespace std; class TestClass { private; char c; public; TestClass (char n):c(n){} ~TestClass () { cout<<c; } }; class TestClass1:public TestClass { Private: char c; public: TestClass1(char n):TestClass (n+1),c(n){} ~TestClass1() { cout<<c; } }; int main() { TestClass1 obj('x'); return 0; } 执行上面的程序输出( )。
A.xy
B.yx
C.x
D.y