以下语句中,输出结果与众不同的一个是()A、cout<<"1. "<<setfill(’ ’)<< "Hello! "<<endl;B、cout<<"1."<<’ ’ <<"Hello! /n";C、cout<<"1. Hello! "<<endl;D、cout<<"1. "<<setw(7)<< "Hello! ";

题目

以下语句中,输出结果与众不同的一个是()

  • A、cout<<"1. "<<setfill(’ ’)<< "Hello! "<<endl;
  • B、cout<<"1."<<’ ’ <<"Hello! /n";
  • C、cout<<"1. Hello! "<<endl;
  • D、cout<<"1. "<<setw(7)<< "Hello! ";

相似考题
参考答案和解析
正确答案:B
更多“以下语句中,输出结果与众不同的一个是()A、cout<<"1. "<<setfill(’ ’)<< "Hello! "<<endl;B、cout<<"1."<<’ ’ <<"Hello! /n";C、cout<<"1. Hello! "<<endl;D、cout<<"1. "<<setw(7)<< "Hello! ";”相关问题
  • 第1题:

    有如下4个语句:\n①cout~A~setfill(~*~)leftsetw(7)~B~endl;\n②coutsetfill(~*~)leftsetw(7)~A~~B~endl;\n③cout~A~serfill(~*~)rightsetw(7)~B~endl;\n④coutsetfill(~*~)rightsetw(7)~A~~B~endl;\n其中能显示A******B的是

    A、①和③

    B、①和④

    C、②和③

    D、②和④


    参考答案:A

  • 第2题:

    下面选项中,不属于C++语句的是( )。

    A.{;}

    B.cout<<"Hello!"<<endl

    C.;

    D.{int i=1;int f=i;cout<<f<<endl;}


    正确答案:B
    解析:选项A和选项D是复合语句,C是空语句,而选项B中没有以“;”结尾,这不是C++语句。

  • 第3题:

    有如下4个语句:①cout~A~setfill(~*~)leftsetw(7)~B~endl;②coutsetfill(~*~)leftsetw(7)~A~~B~endl;③cout~A~serfill(~*~)rightsetw(7)~B~endl;④coutsetfill(~*~)rightsetw(7)~A~~B~endl;其中能显示A******B的是

    A、①和③

    B、①和④

    C、②和③

    D、②和④


    参考答案:A

  • 第4题:

    下列程序的输出结果是______。includeusing namespace std;int main() {char a []="He

    下列程序的输出结果是______。 #include<iostream> using namespace std; int main() { char a []="Hello, World"; char *ptr=a; while (* ptr) { if(*ptr)= 'a'&& *ptr' <= 'z') cout << char(*ptr+'A'-'a'); else cout << *ptr; ptr++; } return 0; }

    A.HELLO,WORLD

    B.Hello,World

    C.hELLO, wORLD

    D.hello,world


    正确答案:A
    解析:对于str的每个字母,如果是大写字母或者是非字母,就直接打印出来。如果是小写字母,就转化成大写字母,然后打印。‘A’-‘a’正是大小写字母的ASCII码之差。

  • 第5题:

    下面程序的执行结果是【】。 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

  • 第6题:

    下列程序的输出结果为 include void main( ) { char * a[ ] ={"hello},"the"," wo

    下列程序的输出结果为

    #include<iostream.h>

    void main( )

    {

    char * a[ ] ={"hello},"the"," world"};

    char * * pa=a;

    pa++;

    cout < < * pa < < endl;

    }

    A.hello

    B.the

    C.world

    D.hellotheworld


    正确答案:B
    解析:本题主要考查的是指针数组和指向指针的指针之间的关系,其中a是指针数组,pa是指向指针数组行的指针,所以pa自加1相当于指向下一行。

  • 第7题:

    与C语言 prinft("Hello word/n");语句功能相同的C++语句是( )。

    A.cout>>"Hello world\n";

    B.cin>>"Hello wofld\n;

    C.cout<<"Hello world\n";

    D.cin<<"Hello wofld\n;


    正确答案:C

  • 第8题:

    执行语句:cout<<setfill('*')<<setw(10)<<setfill('#')<<left<<123<<"OK"<<endl;后将输出

    A.123*******OK

    B.123#######OK

    C.123********OK********

    D.123#######OK########


    正确答案:B
    解析:本题考核格式控制数据的输入输出。函数setfill(charc)用于设置填充字符,在输出数据时,如果数据宽度小于设置的宽度,则空闲位置要用填充字符填满,设置的填充符一直有效,直到再次设置填充字符为止,如题中调用函数setfill('*')将填充字符设置为'*',后又调用函数setfill('#')将填充字符设置为'#'。函数setw(intn)用于设置输入输出宽度,宽度设置的效果只对一次输入或输出有效,在完成一次数据的输出或输入后,宽度设置自动恢复为0,如题中语句以宽度10输出数据“123”后,字符串“OK”的输出宽度就自动恢复为0了。而且题中输出的对齐方式为在输出宽度内左对齐。所以最终的输出为123#######OK。

  • 第9题:

    在C++语言中输出“Hello World”的语句是()。A.cout<<"Hello World";B.cout>>"Hello World";C.cin<<

    在C++语言中输出“Hello World”的语句是( )。

    A.cout<<"Hello World";

    B.cout>>"Hello World";

    C.cin<<"Hello World";

    D.cin>>"Hello World";


    正确答案:A
    解析:cout格式输出。

  • 第10题:

    下列语句中,输出与众不同的是

    A.cout<<"1."<<setfill('')<<"Hello!"<<endl;

    B.cout<<"1."<<''<<"Hello! \n";

    C.cout<<"1. Hello!"<<endl;

    D.cofit<<"1."<<setw(7)<<"Hello!";


    正确答案:A
    解析:本题主要考察setfill的用法。只用在设置了宽度的情况下,字符填充操作setfill才有意义。另外要注意的是设置宽度setw是所有格式中唯一一个一次有效的设置。

  • 第11题:

    下列程序的输出结果是 include usingnamespacestd; int main () {chara []="Hello,W

    下列程序的输出结果是 #include <iostream> using namespace std; int main () { char a [] = "Hello,World": char*ptr = a; while (*ptr) { if(*ptr>= 'a' &&*ptr <='z' cout<<char{*ptr+'A'-'a'); else cout<<*ptr; ptr++; } return 0; }

    A. HELLO. WORLD

    B. Hello, World

    C. hELLO, wORLD

    D. hello, world


    正确答案:A
    解析:本题考核while语句和if语句,while语句中if语句的作用是将小写字母变成大写字母输出、所以main函数的字符串通过while语句全部输出为大写字母。

  • 第12题:

    单选题
    以下语句中,输出结果与众不同的一个是()
    A

    cout<<1. <<setfill(’ ’)<< Hello! <<endl;

    B

    cout<<1.<<’ ’ <<Hello! /n;

    C

    cout<<1. Hello! <<endl;

    D

    cout<<1. <<setw(7)<< Hello! ;


    正确答案: B
    解析: 暂无解析

  • 第13题:

    下面程序的执行结果是______。 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'。

  • 第14题:

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

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

    include<iostream.h>

    include<iomanip.h>

    using namespace std;

    voidmain()

    {

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

    cout<<"Hello"<<end1;

    }


    正确答案:xxxxxHello
    xxxxxHello 解析:此题考查的是I/O的格式化输出。Setfill('x')表示填充字符为V,并且一直有效;setw(10)表示将输入输出的宽度设置为10,宽度设置的效果只对以此次输入或输出有效,在完成一个数据的输入或输出后,宽度自动恢复为0;题目中字符串“Hello”的宽度不够10,所以其前面将有5个填充符V。

  • 第15题:

    下列实现C语言语句printf("Hello!")的相同功能的语句是( )。

    A.cout>>"Hello!"

    B.cin>>"Hello!"

    C.cout<<"Hello!"

    D.cin<<"Hello!"


    正确答案:C
    解析:C++输出语句语法。

  • 第16题:

    有如下类和对象的定义:class MyHello{public:static string getName() { return "Hello"; }};MyHello my;下列各组语句中,能输出“Hello”的是( )。

    A. cout<

    B.cout<

    C.cout<

    D.cout<


    参考答案:B

  • 第17题:

    下列程序的输出结果为( )。 #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++访问数组第二个元素。

  • 第18题:

    下列语句中,输出与众不同的是

    A.cout<<" 1. "<<setfill(' ') <<" Hello ! "<<end1

    B.cout<<"1. "<<"<"Hello!"\n";

    C.cout<<"1. Hello!"<<end1;

    D.cout<<'1. "<<setw(7)<<"Hello! ";


    正确答案:A
    解析:本题主要考察setfill的用法。只用在设置了宽度的情况下,字符填充操作setfill才有意义。另外要注意的是设置宽度setw是所有格式中惟一一个一次有效的设置。

  • 第19题:

    下列程序的输出结果为includevoid main(){char*a[]={"hello","the","world"};char*

    下列程序的输出结果为 #include<iostream.h> void main() { char*a[]={"hello","the","world"}; char**pa=a; pa++; cout<<*pa<<end1; }

    A.hello

    B.the

    C.world

    D.hello the world


    正确答案:A
    解析:本题考查的是字符数组的初始化,选项B)中用3个元素初始化大小为2的数组,越界了;选项C)中应该是2行3列的数组,题中使用3行2列初始化;选项D)中数组合后应用方括号。

  • 第20题:

    有如下4个语句: ①cout<<‘A’<<setfill(‘*’)<<1eft<<setw(7)<<‘B’<<endl; ②cout<<setrill(‘*’)((1eft<<setw(7)<<‘A’<<‘B’<<endl; ③cout<<‘A’<<serfill(‘*’)<<right<<setw(7)<<‘B’<<endl; ④cout<<setfill(‘x’)<<right<<setw(7)<<‘A’<<‘B’<<endl;

    A.①和③

    B.①和④

    C.②和③

    D.②和④ 其中能显示A* * * * * *B的是( )。


    正确答案:C
    解析: 本题考查C++流的使用。setfill()作用是设置填充字符;left是使输出数据在指定宽度内左对齐;right是使输出数据在指定宽度内右对齐。

  • 第21题:

    有如下四个语句: ①cout<<A<<seifill(*)<<left<<setw(7)<<B<<endl; ②cout<<setfill(*)<<left<<setw(7)<<A<<B<<endl; ③cout<<A<<serfill(*)<<right<<setw(7)<<B<<endl; ④cout<<setfill(*)<<right<<setw(7)<<A<<B<<endl; 其中能显示A******B的是( )。

    A.①和③

    B.①和④

    C.②和③

    D.②和④


    正确答案:C

    C。【解析】本题考查C++流的使用。setfill的作用是设置填充字符;left的作用是使输出数据在指定宽度内左对齐;right的作用是使输出数据在指定宽度内右对齐。

  • 第22题:

    设char str1[11]="HELLO,",str2[10]=“world”;则执行语句cout<

    设char str1[11]="HELLO,",str2[10]=“world”;则执行语句 cout<<strlen(strcpy(str1,str2)));后的输出结果是 ______。

    A.12

    B.11

    C.7

    D.5


    正确答案:D

  • 第23题:

    下列程序的执行结果为______。include void main() { cout.fill(‘*’); tout.width(10

    下列程序的执行结果为______。

    include<iostream.h>

    void main()

    {

    cout.fill(‘*’);

    tout.width(10);

    cout<<“hello”<<endl;

    )


    正确答案:* * * * *hello。
    * * * * *hello。 解析: 本题考查的是C++语言的流输出操作,eout中包括的函数fill()和width()分别实现填充和设定显示长度的功能。