下面程序的输出结果是()。includeusing namespace std;void main(){char cl='a',c2='c下面程序的输出结果是( )。 #include<iostream> using namespace std; void main() { char cl='a',c2='c'; cout.put('a').put('c').put('\n'); cout.put(c1).put(c2); }A.ac a cB.ac acC.a c ac cD.a c

题目
下面程序的输出结果是()。includeusing namespace std;void main(){char cl='a',c2='c

下面程序的输出结果是( )。 #include<iostream> using namespace std; void main() { char cl='a',c2='c'; cout.put('a').put('c').put('\n'); cout.put(c1).put(c2); }

A.ac a c

B.ac ac

C.a c ac c

D.a c


相似考题
更多“下面程序的输出结果是()。#include<iostream>using namespace std;void main(){char cl='a',c2='c ”相关问题
  • 第1题:

    程序的输出结果是【 】。 include using namespace std; class A{ int x; public: A(int

    程序的输出结果是【 】。

    include <iostream>

    using namespace std;

    class A{

    int x;

    public:

    A(int x=1):x(x){cout<<x;}

    };

    void main(){

    A a,b(2),c(3);

    }


    正确答案:123
    123 解析:a对象使用和默认的构造函数,b对象使用2来初始化对象c对象使用3来初始化对象,输出相应的值后,结果变为123。

  • 第2题:

    下面程序的执行结果是______。 include include using namespace std; vo

    下面程序的执行结果是______。

    include<iostream.h>

    include<iomanip.h>

    using namespace std;

    void main()

    {

    cout<<setfill('x')<<setw(10);

    cout<<"Hello"<<endl;

    }


    正确答案:xxxxxHello
    xxxxxHello 解析:本题考核I/O的格式化输出。setfill('x')表示填充字符为'x',并且一直有效,直到再次设置填充字符为止。setw(10)表示将输入输出宽度设置为10,当实际数据宽度小于指定的宽度时,多余的位置用填充字符填满;当实际数据的宽度大于设置的宽度时,仍按实际的宽度输出。宽度设置的效果只对一次输入或输出有效,在完成一个数据的输入或输出后,宽度设置自动恢复为0(表示按数据实际宽度输入输出)。题中字符串“Hello”的宽度不够10,所以其前面将有5个填充符 'x'。

  • 第3题:

    下列程序的输出结果是______。 include using namespace std; void fun(int &rf) {

    下列程序的输出结果是______。

    include<iostream>

    using namespace std;

    void fun(int &rf)

    {

    rf*=2;

    }

    int main()

    {

    int num=500;

    fun(num);

    cout<<num<<endl;

    return 0;

    }


    正确答案:1000
    1000 解析:本题考核引用作为函数参数的使用。引用作为形参时,它实际上就是实参,函数对形参的访问和修改就是对实参的访问和修改,题中函数fun对形参的操作是自增2倍,所以经过函数调用后,实参的值自增2倍,即输出1000。

  • 第4题:

    下面程序的执行结果是【】。 include include using namespace std; void main(

    下面程序的执行结果是【 】。

    include<iostream>

    include<iomanip>

    using namespace std;

    void main()

    {

    cout<<setfill('x')<<setw(10);

    cout<<"Hello"<<endl;

    }


    正确答案:xxxxxHello
    xxxxxHello

  • 第5题:

    下列程序的输出结果是( )。 include using namespace std; int main() {

    下列程序的输出结果是( )。 #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


    正确答案:C
    解析:用一个指针变量p指向字符数组a,在while循环中,当不指向数组尾时,将小写字母转换为大写字母,然后将其输出。

  • 第6题:

    以下程序的输出结果是()。includeusing namespace std;void fun(char**q){++q;cout<<*

    以下程序的输出结果是( )。 #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


    正确答案:C
    解析:由程序main主函数入手,调用fun函数,在fun函数中执行“cout*qend1;”语句实现程序输出。主函数中变量char*s[]为指针数组,char**p表示p指向的字符指针数据。*p就代表p指向的字符指针。语句“p=s;”表明p指向字符指针s,而**p则是s[]中的第一个字符串“HI”。主函数将变量p传值给函数fun(char**q)中的q,在函数体内部首先执行“++q”语句,就是将q的指针指向s中的下一个字符串,即“HELL0”,所以输出语句“cout*qend1;”输出该字符串值。

  • 第7题:

    下列程序的输出结果是【】。 include include using namespace std; void fun(c

    下列程序的输出结果是【 】。

    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;

    }


    正确答案:C
    C

  • 第8题:

    若有以下程序: include using namespace std; int main() {char str[10];cin>>str;co

    若有以下程序:

    include <iostream>

    using namespace std;

    int main()

    {

    char str[10];

    cin>>str;

    cout<< str<<end1;

    return 0;

    }

    当输入为:

    This is a program!

    那么执行程序后的输出结果是【 】。


    正确答案:This
    This 解析:本题考核C++的标准输入/输出。提取符可以从输入流中读取一个字符序列,即一个字符串。在处理这种字符序列时,字符串被认为是一个以空白字符结束的字符序列。因此,本题得到的输入仅仅是第一个空白符之前的字符序列 This。所以程序最后的输出是This。

  • 第9题:

    下面程序执行的结果是【 】 include using namespace std; class A{ public: static in

    下面程序执行的结果是【 】

    include<iostream>

    using namespace std;

    class A{

    public:

    static int x;

    A(inty){cout<<x+y;}

    };

    int A::x=2;

    void main(){

    A a(5);

    }


    正确答案:7
    7 解析:程序的静态变量初始化为2,而构造函数招待过程中y变量为初始化为5,故程序执行的结果为7。

  • 第10题:

    下面程序的输出结果是()。include using namespace std;void main( ){int i=8,*p=0; p

    下面程序的输出结果是( )。 #include <iostream> using namespace std; void main( ) { int i=8,*p=0; p = &i; coat<<p; }

    A.0

    B.变量i的地址

    C.*p=0; 是错误的,因为不可给指针型变量赋予常数值

    D.8


    正确答案:B
    解析:可以把0赋给指针变量。

  • 第11题:

    当输入“d”时(“”代表空格),下列两段程序的输出结果是()。include includeu

    当输入“d”时(“”代表空格),下列两段程序的输出结果是( )。 #include<iostream> #include<iostream> using namespace std; using namespace std; void main() void main() {char c; {char c; cin>>c;cout<<c;} cin.get(c);cout.put(c);}

    A.与d

    B.与u

    C.d与

    D.d与d


    正确答案:C
    解析:提取符“>>”忽略空白字符,get()函数能够提取空白字符。

  • 第12题:

    下面程序的输出结果是()。includeusing namespace std;void main(){ int a,b; for(a=1

    下面程序的输出结果是( )。 #include<iostream> using namespace std; void main() { int a,b; for(a=1,b=l;a<=100;a++) { if(b>=10) break; if(b%3= =1) { b+=3;continue; } } cout<<a; }

    A.101

    B.6

    C.5

    D.4


    正确答案:D
    解析:该题是对for循环语句、条件语句、中断语句的综合考察。循环for语句执行了4次,当执行第4次循环的时候b=10退出循环,输出a的值为4。

  • 第13题:

    若下面程序运行时输出结果为1,A,10.1 2,B,3.5 include using namespace std; int mai

    若下面程序运行时输出结果为

    1,A,10.1

    2,B,3.5

    include <iostream>

    using namespace std;

    int main()

    {

    void test(int, char, doubie【 】);

    test(1, 'A', 10.1 );

    test(2, 'B');

    return 0;

    }

    void test(int a, char b, double c)

    {

    cout<<a<<','<<b<<','<<c<<endl;

    }


    正确答案:3.5
    3.5 解析:本题考查了函数默认参数的应用。本题定义的函数test()仅仅是按顺序输出了三个形参值,题目中第1次调用该函数会输出1,A,10.1,但第2次调用少了一个实参却要求输出2,B,3.5。由此可见,应该将test()函数的第3个参数声明为默认参数,且默认值为3.5。故应该填入=3.5,或加上形参名c=3.5。

  • 第14题:

    以下程序的输出结果是【】。 include using namespace std; void fun() {static int a=0

    以下程序的输出结果是【 】。

    include <iostream>

    using namespace std;

    void fun()

    {

    static int a=0;

    a+=2;

    cout<<a;

    }

    int main()

    {

    int CC;

    for(CC=1;cc<4;CC++)

    fun();

    cout<<end1;

    return 0;

    }


    正确答案:246
    246 解析:本题考核函数调用和静态变量。在主函数中通过一个for循环调用了3次fun()函数。第1次调用fun()函数时,a的初始值为0,执行语句“a+=2;”后, a的值为2,输出2;第2次调用时,a的初始值为2,执行语句“a+=2;”后,a的值为4,最后输出4:第3次调用时,a的初始值为4,执行语句“a+=2:”后,a的值为6,最后输出6。

  • 第15题:

    下面程序运行输出的结果是【】。 include using namespace std; int main(){char a[]="C

    下面程序运行输出的结果是【 】。

    include <iostream>

    using namespace std;

    int main(){

    char a[]="Chinese";

    a[3]='\0';

    cout<<a<<endl;

    return 0;

    }


    正确答案:Chi
    Chi 解析:字符串的结束标识是'\0',输出字符串时,到第一个'\0'输出结束,而不管其后是否还有数据,因此本题输出为字符中的前3个字符。

  • 第16题:

    下列程序的输出结果为( )。 #include (iostream) using namespace std; void main( ) char,a[ ] = { "hello" ," the" ," world" }; char * * pa = a: pa + +; cout << * pa << ENDL; }

    A.hello

    B.the

    C.world

    D.hellotheworld


    正确答案:B
    解析:指针与数组对应关系,*p++访问数组第二个元素。

  • 第17题:

    下面程序输出的结果是( )。 include using namespace std; void swap(int

    下面程序输出的结果是( )。 #include <iostream> using namespace std; void swap(int &a,int &b){ int temp; temp=a; a=b; b=temp; } void main(){ int x=2; int y=3; swap(x,y); cout<<x<<y; }

    A.23

    B.32

    C.ab

    D.ba


    正确答案:B
    解析:函数的参数是引用,故能实现引用调用。

  • 第18题:

    下面程序的输出结果是( )。include using namespace std;void main(){int s;for(int k

    下面程序的输出结果是( )。#include <iostream>using namespace std;void main(){int s;for(int k=2;k<6;k+=2)s=1;for(int j=k; j<6;j++) s+=j;cout<<s<<end1;

    A.9

    B.1

    C.11

    D.10


    正确答案:D

  • 第19题:

    下面程序输出的结果是()。includeusing namespace std;void main(){ char ch[][8]={"g

    下面程序输出的结果是( )。 #include<iostream> using namespace std; void main() { char ch[][8]={"good","better","best"}; for(int i=1;i<3;++i) { cout<<ch[i]<<endl; } }

    A.good better

    B.better best

    C.good best

    D.good


    正确答案:B
    解析:二维数组ch共3行8列,for循环语句输出第2、3行的数组元素

  • 第20题:

    下列程序的输出结果是______。includeinclude using namespace std;void

    下列程序的输出结果是______。

    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;

    }


    正确答案:C
    C 解析:本题考核数组的定义、使用以及函数的调用。fun函数的作用是将字符串str中间的字符赋值给地址传入的变量ch。所以ch的值将被修改为‘C’。

  • 第21题:

    以下程序的输出结果是()。includeincludeusing namespace std;void func(cha

    以下程序的输出结果是( )。 #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


    正确答案:C

  • 第22题:

    以下程序的运行结果是【】。 include include using namespace std; void main()

    以下程序的运行结果是【 】。

    include<iostream>

    include<string>

    using namespace std;

    void main(){

    chara[10]="China",b[]="Chin",c[]="ese";

    cout<<strlen(strcat(strcpy(a,b),c))<<endl;

    }


    正确答案:7
    7 解析:本题主要考查C++中字符串函数的使用。strcpy(s1,s2)将s2的内容赋值到s1中; strcat(s1,s2)连接s1和s2两个字符串;strlen(s)返回字符数组s的长度。因此最后输出的结果是b和c进行连接后的字符串长度,即7。

  • 第23题:

    下面的程序输出的结果是( )。 include using namespace std; void main(){

    下面的程序输出的结果是( )。 #include <iostream> using namespace std; void main(){ int a=2; int &c=a; a++; cout<<c; }

    A.2

    B.3

    C.4

    D.*a


    正确答案:B
    解析:c是a的引用,故a++相当于c++。