网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

以下方法的功能是统计字符串中数字字符的个数。请在空白处填入适当内容,把程序补充完整。 static int count(string s) { int r=0; for(int i=0;i<s.Length;i++) { if(_______) __r++___; } return r; }


参考答案和解析
B 过程中对传人的字符串的字符一个个取出,判断如果不是空格则依次连接到一个字符串变量中,如果是空格则计数加1。最后,返回不包含空格的字符串和空格的个数。因此选项B正确。
更多 “以下方法的功能是统计字符串中数字字符的个数。请在空白处填入适当内容,把程序补充完整。 static int count(string s) { int r=0; for(int i=0;i<s.Length;i++) { if(_______) __r++___; } return r; }” 相关考题
考题 下面程序的运行结果是【】。 inChlde using namespace std; class count { static int n; 下面程序的运行结果是【 】。inChlde<iOStream>using namespace std;class count{static int n;public:count(){n++;}static int test(){for(int i=0:i<4;i++)n++;return n;}};int count::n=0;int main(){cout<<COUnt::test()<<" ";count c1, c2;cout<<count::test()<<end1;return 0;}

考题 以下程序的输出结果是int f(){ static int i=0;int s=1;s+=i; i++;return s; }main(){ int i,a=0;for(i=0;i5;i++)a+=f();printf("%d\n",a);}A.20B.24C.25D.15

考题 str是一个由数字和字母字符组成的字符串,由变量num传人字符串长度。请补充函数proc,该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。 例如,str="abcl23de45f967",结果为:l234567。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。 试题程序: includestdio.h define M 80 int bb[M]; int proc(char str[],int bb[],int num) { int i,n=0; for(i=0;inum;i++) { if( 【1】 ) { bb[n]=【2】 ; n++; } } return 【3】 ; } void main { char str[M]; int num=0,n,i; printf("Enter a string:\n"); gets(str); while(str[num]) num++: n=proc(str,bb,num); printf("\nbb="); for(i=0;in;i++) printf("%d",bb[i]); }

考题 有以下程序:includeint a=4;int f(int n){int t=0;static int a=5;if(n%2) {int a=6; 有以下程序: #include<string.h> int a=4; int f(int n) {int t=0;static int a=5; if(n%2) {int a=6;t++=a++;} else{int a=7;t+=a++;} return t+a++; } main() {int s=a,i=0; for(;i<2;i++)s+=f(i); printf("%d\n",s); } 程序运行后的输出结果是( )。A.24B.28C.32D.36

考题 以下程序的执行结果是【】。 include int f(int b[],int n) { int i,r=1; for(i=0;i 以下程序的执行结果是【 】。include<iostream.h>int f(int b[],int n){int i,r=1;for(i=0;i<n;i++)r=r*b[i];return r;}void main(){int x,a[]={2,3,4,5,6,7,8,9};x=f(a,3);cout<<x<<endl;}

考题 下面的程序是10000以内的“相亲数”。所谓相亲数是指这样的一对数:甲数的约数之和等于乙数,而乙数的约数等于甲数,(例如220和284是一对相亲数)请在程序的每条横线处填写一条语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class QinShu{public static void main(String args[ ]){for(int n=1;n<9999;n++){int s=divsum(n);if( )System.out.println(n+","+s);}}public static int divsum(int n){//该方法的功能是求一个数的所有约数int s=0;for(int i=1;____________________i++)if(____________________)s+=i;return s;}}

考题 下面程序的运行结果是【】。 include using namespace std; class count{ static int n; 下面程序的运行结果是【 】。include <iostream>using namespace std;class count{static int n;public:count(){n++;}static int test(){for(int i=0;i<4;i++)n++;return n;}};int count::n = O;int main(){cout<<count:: test()<<" ";count c1, c2;cout<<count:: test()<<endl;return 0;}

考题 str是一个由数字和字母字符组成的字符串,由变量hum传入字符串长度。请补充函数fun( ),该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。例如:str=“Bcdl23e456hui890”,结果为:123456890。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>define N 80int bb[N];int fun(char s[ ],int bb[ ],int num){int i,n=0;for(i=0;i<num;i++){if(【 】){bb[n]=【 】;n++;}}return【 】;}main(){char str[N];int num=0,n,i;printf("Enter a string:\n");gets(str);while(str[num])num++;n=fun(str,bb,num);printf("\nbb=");for(i=0;i<n;i++)printf("%d",bb[i]);}

考题 以下程序的输出结果是 include int f( ) { static int i=0; int s=1 s+ =i; 以下程序的输出结果是 #include<iostream.h> int f( ) { static int i=0; int s=1 s+ =i; i++; return s;} void main( ) { int i,a=0; for(i=0 ;i<5;i++)a+=f( ); cout < < a;}A.20B.24C.25D.15

考题 有以下程序: include using namespace std; int f(int); int main() {int i;for(i=0; 有以下程序:include <iostream>using namespace std;int f(int);int main(){int i;for(i=0;i<5;i++)cout<<f(i)<<" ";return 0;}int f(int i){static int k=1;for(;i>0;i--)k+=i;

考题 若有以下程序:include using namespace std;int f(){static int i = O;ints= 1;s+=i; 若有以下程序:#include <iostream>using namespace std;int f(){ static int i = O; ints= 1; s+=i; i++; return s;}int main(){ int i, a =0; for(i=0;i<5;i++) a+=f(); cout<<a<<end1; return 0;}程序运行后,输出的结果是( )。A.20B.24C.25D.15

考题 若有以下程序:include using namespace std;int f(){static int i = 0;int s = 1;s+= 若有以下程序: #include <iostream> using namespace std; int f() { static int i = 0; int s = 1; s+=i; i++; return s; } int main() { int i,a = 0; for(i = 0;i<5;i++) a+=f(); cout<<a<<endl; return 0; } 程序运行后,输出的结果是A.20B.24C.25D.15

考题 有以下程序: int a=2; int f(int n) { static int a=3; int t=0; if(n % 2)(static int a=4; t+=a++;} else{static int a=5; t+=a++;} return t+a++; } matin() { int s=a, i; for(i=0; i<3; i++)s+=f(i); printf("% d\n", s); } 程序运行后的输出结果是______。A.26B.28C.29D.24

考题 若有以下程序:includeusing namespace std;int f(){ static int i=O; int s=1; s+=i; 若有以下程序: #include<iostream> using namespace std; int f() { static int i=O; int s=1; s+=i; i++; return s; } int main() { int i,a=0; for(i=0;i<5;i++) a+=f(); cout<<a<<endl; retrun 0; } 程序运行后,输出的结果是A.20B.24C.25D.15

考题 以下程序的输出结果是【 】。include int fun(int x) {static int t=0; return(t+=x); } 以下程序的输出结果是【 】。include <stdio.h>int fun(int x){ static int t=0;return(t+=x);}main()int s,i;for(i=1 ;i<=5;i++) s=fun(i);printf("%d\n",s);

考题 若有以下程序: include using namespace std;int f(){static int i = 0;ints= 1;s+=i 若有以下程序: #include <iostream> using namespace std; int f() { static int i = 0; ints= 1; s+=i; i++; return s; } int main() { int i,a = 0; for(i = 0;i<5;i++) a+=f(); cout<<a<<endl; return 0; } 程序运行后,输出的结果是A.20B.24C.25D.15

考题 以下程序的输出结果是#include stdio.hint fun(int x){ static int m=0; return(m *=x);}main(){ int s,i; for(i=l;i=3;i++) s=fun(i); printf("%d\n",s);}

考题 以下程序的输出结果是intf(){ static int i= 0; int s=1; s+=i; i++; return s;}main( ){ inti, a=0; for(i=0;i<5;i++)a+=f(); cout<<a<<end1;}A.20B.24C.25D.15

考题 有以下程序:include using namespace std;class count{ static int n;public: count 有以下程序: #include <iostream> using namespace std; class count { static int n; public: count ( ) { n++; } static int test() { for (int i = 0; i < 4; i++ ) n++; return n; } }; int count :: n = 0; int main() { cout<<count :: test()<<" "; count c1, c2; cout<<count :: test()<<end1; return 0; } 执行后的输出结果是( )。A.4 10B.1 2C.22D.24

考题 以下程序的输出结果是 ______。includeInt f(){static int i=0;int a=1;a+=;i++;ret 以下程序的输出结果是 ______。 #include<iostream.h> Int f(){ static int i=0; int a=1; a+=; i++; return a; } void main() { int i,s=0; for(i=0;i<4;i++) s+=f(); cout<<s;A.10B.15C.21D.28

考题 若有以下程序:includeusing namespace std;int fun(){static int i=0;int s=1;s+=i;i 若有以下程序: #include<iostream> using namespace std; int fun() { static int i=0; int s=1; s+=i; i++; return s; } int main() { int i,a=0; for(i=0;i<5;i++) a+=fun(); cout<<a<<endl; return 0; } 程序运行后,输出的结果是( )。A.20B.24C.26D.15

考题 下面程序的功能是()。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 int a =2;int f(int n){ static int a: 3;intt=0;if(n%2){ stat 有以下程序: #include <stdio, h>int a =2;int f(int n){ static int a: 3; int t=0; if(n%2){ static int a=4;t+ =a++;} else { static int a=5;t+ :a++;} return t + a + +;main ( ){ int s=a,i; for(i=0;i<3;i++)s + =f(i); prinff("% d \n" ,s); }程序运行后的输出结果是( )。A.26B.28C.29D.24

考题 以下程序的输出结果是intf( ){static int i=0;int s=1;s+=i;i++;return s;}main( ){int i,a=0;for(i=0;i<5;i++)a+=f( );cout<<a<<endl;}A.20B.24C.25D.15

考题 有以下程序 int a=2; int f(int n) { static int a=3; int t=0; if(n%2) {static int a=4; t+=a++;} else {static int a=5; t+=a++;} return t+a++; } main ( ) { int s=a, i; for (i=0;i<3; i++) s+=f (i) print f ("%d\n" , s ); } 程序运行后的输出结果是A.26B.28C.29D.24

考题 若有如下程序: include using namespaee std; int fun() { static int i=0; int s=1; 若有如下程序: #include<iostream> using namespaee std; int fun() { static int i=0; int s=1; s+=i; i++; return s; } int main() { int i,a=0; for(i=0;i<5;i++) a+=fun(); cout<<a<<end1; return 0; } 程序运行后,输出的结果是( )。A.20B.24C.25D.15

考题 以下程序的执行结果是______ include int f(int b[],int n) { int i,r=l; for(i=0; 以下程序的执行结果是______include<iostrearn.h>int f(int b[],int n){int i,r=l;for(i=0;i<n;i++)r=r*b[i];return r;}void main(){int x,a[]= {2,3,4,5,6,7,8,9};x=f(a,3):cout<<x<<endl;}

考题 阅读以下说明和C语言程序,将应填入(n)处的字句写在对应栏内。【说明】以字符流形式读入一个文件,从文件中检索出6种C语言的关键字,并统计、输出每种关键字在文件中出现的次数。本程序中规定:单词是一个以空格或'\t'、'\n'结束的字符串。其中6种关键字在程序中已经给出。【程序】include <stdio.h>include <stdlib.h>FILE *cp;char fname[20], buf[100];int NUM;struct key{ char word[10];int count;}keyword[]={ "if", 0, "char", 0, "int", 0,"else", 0, "while", 0, "return", 0};char *getword (FILE *fp){ int i=0;char c;while((c=getc(fp))!= EOF (1));if(c==EOF)return (NULL);elsebuf[i++]=c;while((c=fgetc(fp))!=EOF c!=" c!='\t' c!='\n' )buf[i++]=c;buf[i]='\0';return(buf);}void lookup(char *p){ int i;char *q, *s;for(i=0; i<NUM; i++){ q=(2);s=p;while(*s (*s==*q)){ (3))if((4)){ keyword[i].count++;break;}}return;}void main(){ int i;char *word;printf("lnput file name:");scanf("%s", fname);if((cp=fopen(fname, "r"))==NULL){ printf("File open error: %s\n", fname);exit(0);}NUM=sizeof(keyword)/sizeof(struct key);while((5))lookup(word);fclose(cp);for(i=0;i<NUM;i++)printf("keyword:%-20s count=%d\n",keyword[i].word,keyword[i].count);}