阅读以下程序 #include(iostream.h>voidmain( ) {charline[10]; cin>>line; cout<&

题目

阅读以下程序

#include(iostream.h>

voidmain( )

{

charline[10];

cin>>line;

cout<<1ine<<endl;

}

如运行时输入“Thisisanexample.<CR>”,则程序的输出结果是( )。

A.This

B.Thisis

C.Thisisa

D.Thisisanexample

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

阅读以下程序 include void main( ) { char line[10]; cin>>line; cout<

阅读以下程序

#include<iostream.h>

void main( )

{

char line[10];

cin>>line;

cout<<line<<endl;

}

如运行时输入This is example.<CR>,则程序的输出结果是

A.This

B.This is

C.This is a

D.This is an example.


正确答案:A
解析:本题考察C++中cin输入流对象的使用规则,其特点是以空格、回车和tab为分隔符。因此this和is之间的空格告诉cin对象停止接收后面的数据。故正确答案为A。

第2题:

阅读以下程序 includc vold main() { Char line[10]; cin>>line;

阅读以下程序 #includc<iostream.h> vold main() { Char line[10]; cin>>line; cout<<line<<endl; } 如运行时输入This is example.<CR>,则程序的输出结果是

A.This

B.This is

C.This is a

D.This is an example.


正确答案:A
解析:本题考察C++中cin输入流对象的使用规则,其特点是以空格、回车和tab为分隔符。因此this和is之间的空格告诉cin对象停止接收后面的数据、故正确答案为A。

第3题:

阅读以下程序includevoid main(){charline[10];in>>line;cout<

阅读以下程序 #include<iostream.h> void main() { charline[10]; in>>line; cout<<line<<endl; } 如运行时输入This is an example.<CR>,则程序的输出结果是( )。

A.This

B.This is

C.This is a

D.This is an example.


正确答案:A
解析: 本题考查C++中cin输入流对象的使用规则,其特点是以空格、回车和tab为分隔符。因此this和is之间的空格告诉cin对象停止接收后面的数据。故正确答案为A。

第4题:

当输入“Thank you”时下列程序的输出结果为()。 include include void m

当输入“Thank you”时下列程序的输出结果为( )。 #include<iostream.h> #include<iomanip.h> void main() { char line[80]; cin.getline(line,sizeof(80),'k'); cout<<line; }

A.Tha

B.Thank you

C.Thank

D.以上结果都不对


正确答案:A

第5题:

写出下列程序的运行结果【】。include .include include void ma

写出下列程序的运行结果【 】。

include <iostream.h>.

include <fstream.h>

include <stdlib.h>

void main()

{

fstream outfile, infile;

outfile.open("data.clat", ios:: out);

if(!outfile)

{

cout<<"Can't open the file."<<end1;

abort();

}

outfile<<" 1234567890"<<end1;

outfile<<"aaaaaaaaa"<<end1;

outfile<<"**********"<<end1;

outfile.close();

infile.open("data. dat ", ios:: in);

if(!infile)

{

cout<<"Can't open the file."<<end1;

abort();

}

char line[80];

int I=0;

while(!infile. eof())

{

I++;

infile.getline(line, sizeof(line));

cout<<I<<":"<<line<<end1;

}

infile.close();

}


正确答案:1: 1234567890 2:aaaaaaaaa 3:********** 4:
1: 1234567890 2:aaaaaaaaa 3:********** 4:

第6题:

阅读以下程序,此程序的功能是【】。 include void main() { intn, i, j; for(i=100;i<9

阅读以下程序,此程序的功能是【 】。

include<iostream.h>

void main()

{

int n, i, j;

for(i=100;i<999; i+100)

for(j=i/100:j<=99;j=j+10)

{

n=i+j;

cout<<" "<<n;

}

cout<<"\n";

}


正确答案:求100到999的回文数
求100到999的回文数

第7题:

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

第8题:

以下不能够读入空格字符的语句是

A.char line; line=cin.get()

B.char line; cin. get(line);

C.char line; cin>>line;

D.char line[2]; cin. getline(line,2);


正确答案:C
解析:本题考察cin流对象的几种成员函数get,getline的使用规则。流提取符>>在提取字符时,遇到C++规定的分隔符如空格,回车和Tab键时自动分割,故本题正确答案为C。

第9题:

阅读以下程序 #include(iostream.h> voidmain( ) { charline[10]; cin>>line; cout<<1ine<<endl; } 如运行时输入“Thisisanexample.<CR>”,则程序的输出结果是( )。

A.This

B.Thisis

C.Thisisa

D.Thisisanexample


正确答案:A
A。【解析】本题考查C++中cin输入流对象的使用规则,其特点是以空格、回车和tab为分隔符。因此this和is之间的空格告诉cin对象停止接收后面的数据。故正确答案为A。

第10题:

当输入“Thank you”时下列程序的输出结果为()。include<includevoid mai

当输入“Thank you”时下列程序的输出结果为( )。 #include<<iostream.h> #include<iomanip.h> void main() { char line[80]; cin.getline(line,sizeof(80),'k'); cout<<line; }

A.Tha

B.Thank you

C.Thank

D.以上结果都不对


正确答案:A