题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-08-01 03:14:39

[单项选择]下面程序的功能是( )。
#include <iostream>
#include <string>
using namespace std;
int main ( )

int i=1, n=0;
char s[80],*p;
p=s;
strcpy(p,"It is a book..");
for (; *p !=’ /0’ ;p++)

if(*p==’’)
i=0;
else if (i==0)
n++; i=1;

cout<<"n=" <<n<<end1;
return 0;

A. 统计字符串中的单词个数
B. 统计字符串中的空格个数
C. 统计字符串中的字母个数
D. 统计字符串中的全部字符个数

更多"下面程序的功能是( )。 #include <iostream> "的相关试题:

[单项选择]下面程序的功能是( )。
#include <iostream>
#include <string>
using namespace std;
int main ( )

int i=1, n=0;
char s[80],*p;
p=s;
strcpy(p,"It is a book..");
for (; *p !=’ /0’ ;p++)

if(*p==’’)
i=0;
else if (i==0)
n++; i=1;

cout<<"n=" <<n<<end1;
return 0;

A. 统计字符串中的单词个数
B. 统计字符串中的空格个数
C. 统计字符串中的字母个数
D. 统计字符串中的全部字符个数
[单项选择]下面程序的输出结果是( )。
#include<iostream>
#include<string>
using namespace std;
void main( )
charp1[10],p2[10];
strcpy(p1,"abc");
strcpy(p2,"ABC");
charstr[50]="xyz";
strcpy(str+2,strcat(p1,p2));
cout<<str;

A. xyabcABC
B. yzabcABC
C. xyzabcABC
D. zabcABC
[填空题]下面程序的执行结果是 【15】 。 #include <iostream> #include <iomanip> using namespace std; void main( ) { cout<<setfill(’x’)<<setw(10); cout<<"Hello"<<end1;
[单项选择]下面程序的输出结果是( )。
#include<iostream>
#include<math.h>
using namespace std;
class point

private:
double x;
double y;
public:
point(double a,double b)

x=a;
y=b;

friend double distances(point a,point b);
;
double distances(point a,point b)

return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));

int main( )

point p1(1,2);
point p2(5,2);
cout<<distances(p1,p2)<<end1;
return 0;

A. 2
B. 4
C. 8
D. 16
[填空题]下面程序的执行结果是 【15】
#include <iostream>
#include <iomanip>
using namespace std;
void main( )cout<<setfill(’x’)<<setw(10);
cout<<"Hello"<<end1;

[单项选择]下面程序的输出结果是
#include<iostream.h>
#include<string.h>
void main( )

char p1[10],p2[10]
strcpy(p1,"abc");
strcpy(p2,"ABC");
char str[50]="xyz";
strcpy(str+2,strcat(p1,p2));
cout<<str;

A. xyzabcABC
B. zabcABC
C. xyabcABC
D. yzabcABC
[填空题]阅读下面程序:
#include <iostream.h>
#include <math.h>
template <class T>
class TAdd

private:
T x,y;
public:
TAdd(T a,T b)x=a;y=b;
T add( ) return x+y;
;
void main( )

TAdd<int>A(5,6); //定义一个对象A
TAdd<double>B(2.4,5.8); //定义一个对象B
cout<<"s1="<<A.add( )<<endl;
cout<<"s2="<<B.add( )<<endl;

写出该程序的运行结果:______。
[填空题]阅读下面程序: #include<iostream> using namespace std; long fib(int n) { if ( n > 2 ) return (fib(n-1)+fib(n-2)); else return 2; } int main( ) { cout<<fib(3)<<end1; return 0; { 则该程序的输出结果应该是 【8】
[单项选择]下面程序的输出结果是
#include<iostream.h>
#include<string.h>
void main( ) char p1[10] ,p2[10] ;
strcpy(p1,"abc") ;
strcpy(p2,"ABC") ;
char str[50] ="xyz";
strcpy(str+2,strcat(p1,p2) ) ;
cout < < str; A) xyzabcABC B) zabcABC C) xyabcABC D) yzabcABC
[填空题]下面程序的输出结果是______。
#include <iostream>
#include <math>
using namespace std;
class point

private:
double x;
double y;
public:
point(double a,double b)

x=a,
y=b;
friend double distance(point a,point b);
;
double distance(point a,point b)

return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b,y)*(a.y-b.y));

int main( )

point p1(1,2);
point p2(5,2);
cout<<distance(p1,p2)<<endl;
return 0;

[填空题]下面程序的执行结果是______。
#include <iostream>
#include <iomanip>
using namespace std;
void main( )

cout<<setfill(’x’)<<setw(10);
cout<<"Hello"<<endl;

[填空题]下面程序的预设功能是:统计文件abc.txt中的字符个数。
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void main( )

fstream file;
file.open( "abc.txt", ios::in);
if ( !file )

cout<<"Can not open abc.txt"<<end1;
abort( );

char ch;
int i = O;
while (______________)

file.get(ch);
i++;

cout<<"Characters : "<<i<<end1;
file.close( );

则程序中空白处应该填入的语句是 【15】
[填空题]下面程序的功能是输出数组s中最小元素,请填空。
#include<iostream.h>
void main( )
int k, p, s[]=1,-9,7,2,-10,3;
k=s[0];
for(p=0;p<6;p++)
if(s[p]<k) [11]
cout<<k;

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码