niusouti.com

下面程序的功能是()。include include using namespace std;int main (){ in下面程序的功能是( )。 #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; els

题目
下面程序的功能是()。include include using namespace std;int main (){ in

下面程序的功能是( )。 #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;int main (){ in ”相关问题
  • 第1题:

    下面程序错误的语句是 #include"iostream.h" ① void main() ② { ③ int A=0; ④ int&B; ⑤ B=A; ⑥ cout<<B; ⑦ cout<<A; ⑧ }

    A.②

    B.③

    C.④

    D.⑥


    正确答案:C

  • 第2题:

    下面程序错误的语句是①include ②void main()③{④int * p=new int[1]⑤p=9⑥cout<<* p<

    下面程序错误的语句是

    ①#include<iostream.h>

    ②void main()

    ③{

    ④ int * p=new int[1]

    ⑤ p=9

    ⑥ cout<<* p<<end1;

    ⑦ delete []p;

    ⑧}

    A.④

    B.⑤

    C.⑥

    D.⑦


    正确答案:B
    解析:本题考查的是指针的使用,p是指向int型的指针,若想给它指向的元素赋值,应使用*符号,直接赋值相当于改变了原来p存储的地址。

  • 第3题:

    分析下面程序的运行结果()。 #include "stdio.h" #include "string.h" main() { printf("%dn",strlen("IBMn012")); }


    A 解析:在解答本题时应该考虑两个问题:结构体变量的长度及sizeof()求字节数的运算符。结构体变量的长度是其内部成员总长度之和,本题中,structdate中包含year,month,day三个整型变量。一个整型变量所占的字节数为2。

  • 第4题:

    下面程序的运行结果是 ( ) include include main( ) { char * a="

    下面程序的运行结果是 ( ) # include<stdio.h> # include<string.h> main( ) { char * a="AbcdEf",* b="aBcD" a + +;b + +; printf("%d\n",strcmp(a,b)); }

    A.0

    B.负数

    C.正数

    D.无确定值


    正确答案:C

  • 第5题:

    当执行下面的程序时,如果输入ABC,写出程序输出结果 #include "stdio.h" #include "string.h" main() { char ss[10]; gets(ss); strcat(ss,"6789"); printf("%sn",ss); }


    A 当执行gets(ss)后,ss数组中的元素为ABC,再执行strcat(ss,″6789″),strcat的作用是把6789连接到ss数组后面,执行完后ss数组为ABC6789,故选择A选项。

  • 第6题:

    【填空题】下面程序的运行结果是 。 #include<stdio.h> #include<string.h> main() {char a[20]="AB",b[20]="LMNP"; int i=0;strcat(a,b); while(a[i++]!='0') b[i]=a[i]; puts(b); }


    abcee