题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-03-19 20:32:54

[单项选择]下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。
public class FindKeyWords
public static void main(sring[]args)
sting text=
"An array is a data structur that stores a collection of"
+"values of the same type. You access each individual value"
+"through an integer index. For example,if a is an array"
+"of inergers,then a[i]is the ith integer in the array.";
Int arrayCount=0;
Int idex=-1;
Sting arrarStr="array";
Index=text.indexof(arravStr);
While(index______0)
++arrayCount;
Index+=arrayStr.length( );
Index=text.indexof(arrayStr,index);

System.out.println
("the text contains"+arrayCount+"arrays");


A. <
B. =
C. <=
D. >=

更多"下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入"的相关试题:

[单项选择]

下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是()
  public class FindKeyWords{
  public static void main(sring[] args){
  sting text=
  “ An array is a data structur that stores a collection of”
  + “values of the same type . You access each individual value”
  + “through an integer index . For example,if a is an array”
  + “of inergers, then a[i] is the ith integer in the array.”;
  Int arrayCount =0;
  Int idex = -1;
  Sting arrarStr =”array”;
  Index = text.indexof(arrayStr);
  While(index 0) {
  ++arrayCount;
  Index += arrayStr.length( );
  Index = text.indexof(arrayStr,index);
  }
  System.out.println
  (“the text contains” + arrayCount + “arrays”);
  }
  }


A. <
B. =
C. <=
D. >=
[填空题]以下程序的功能是统计字符串A中出现字符串B的次数,然后输出,请在填空[9]处填入适当的程序完成功能。
[简答题]

请编写函数fun, 函数的功能是:统计一行字符串中单词的个数,作为函数值返 回。一行字符串在主函数中输入, 规定所有单词由小写字母组成,单词之间由若干 个空格隔开, 一行的开始没有空格。
注意:部分源程序在文件PROG1.C中。
请勿改动主函数main和其它函数中的任何内容, 仅在函数fun的花括号中填入你编写的若干语句。
给定源程序:
#include
#include
#define N 80
int fun( char *s)
{
}
main( )
{ char line[N]; int num=0;
printf("Enter a string :/n"); gets(line);
num=fun( line );
printf("The number of word is : %d/n/n",num);
NONO( );
}


[简答题]请编写函数fun( ),该函数的功能是:统计一行字符串中单词的个数,作为函数值返回。一行字符串在主函数中输入,规定所有单词由小写字母组成,单词之间有若干个空格隔开,一行的开始没有空格。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<string. h>
# include<stdio, h>
#define N 80
int fun (char *s)

main ( )

char line [N];
int num=0;
printf ("Enter a string: /n ");
gets (line);
num=fun (line);
printf ("The number of word is: %d/n/n ",
num);

[简答题]

【程序功能】
统计一个字符串中包含的字母串个数并找出其中最长的字母串。
所谓字母串是指一个连续的字母序列(不区分大小写),字母串之间用非字母字符分隔。函数count的功能是统计p指向的字符串中包含的字母串个数,找出的最长字母串存放在pmax指向的数组中,函数返回字母串的个数。
【测试数据与运行结果】
测试数据:you are teaeher234too.
屏幕输出:a=you are teacher234too.
number is 4
max string is:teacher
【含有错误的源程序】
#include
#include
#include
int count(char p[],char pmax[])
{ int j=0,k,m=0;
char temp[100];
while(*p)
{ while((!isalpha(*p)) && *p) p++;
k=0;
if(*p!=’/0’) m++;
while(isalpha(*p))
temp[k++]=*p++;
temp[k]="/0";
if(k { j=k;
pmax=temp;
}
}
return m;
}

void main( )
{ char a[100]="you are teacher234too.",max[100];
int i;
i=count(a[],max[]);
if(i==0)
printf("a=%S: No letter strings!/n",a);
else
prinff("a=%s/nnumber is %d/nmax string

[填空题]下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串123412132,指定字符1,则输出3。请填空。
#include<stdio.h)
#deftne M 81
int fun(char * ss,char c)
int i=0;
for(; 【18】 ;ss++)
if(*ss==c) i++;
return i;

main( )
char a[M],ch;
printf("/nPlease enter a string:");gets(a);
printf("/nPlease enterachar:");ch=getchar( );
printf("/nThe number of the char is:%d/n",fun(a,ch));

[填空题]下面程序的功能是统计字符串中“广的个数,请填空。   Sub COU( )     a$="Beijing University of Technology"     Dim n AS Integer     n=Len(a$)     For i=1 To n     b$=【 】     If 【 】 Then x=x+1    Next i    Print "x=";x   End Sub
[填空题]下面程序的功能是统计字符串中“i”的个数请填空。
Sub COU( )
Dim n As Integer
a$ =" Beijing University of Technology"
n = Len(a$)
For i = 1 To n
b$ = 【15】
If b$ ="i" Then x=x+1
Next
Print" x="; x
End Sub
[填空题]下面程序的功能是统计字符串中“i”的个数,请填空。
Sub COU( )
Dim n As Integer
a$ = "Beijing University of Technology"
n = Len(a$ )
For i = 1 To n
b$ =Mid$(a$,i, 1)
If 【11】 Then x=x + 1
Next
Print "x ="; x
End Sub
[填空题]下述函数统计—个字符串中的单词个数,单词是指处在空格之间的字符序列,请填空。 int word(char *s) { int num=0,flag=0; while(*s) { if( 【18】 =’’) flag=0; else if( 【19】 ){flag=1;num++} } return 【20】 ;}
[填空题]下述函数统计一个字符串中的单词个数,单词是指处在空格之间的字符序列,请填空。
int word(char*s)
int num=0,flag=0;
while(*s)
if(______=’’) flag=0;
else if(______)flag=1;num++

return______
[简答题]请编写方法int countChar(String s),该方法的功能是统计已知字符串s中字母的个数。例如:countChar("A1Bd56D")的返回值为4。
[填空题]下列这个Sub过程的功能是:统计字符串中“a”的个数,请在空白处填上合适的代码,将程序补充完整。
Private Sub numCount( )
Dim num As Integer
S$="software And hardware"
num=Len(s$)
For i=1 To num
b$=______
Ifb$="a" Then x=x+1
Next i
Print "x=";x
End Sub
[填空题]下列这个Sub过程的功能是:统计字符串中“a”的个数,请在空白处填上合适的代码,将程序补充完整。
Private Sub numCount( )
Dim num As Integer
s$="software And hardware"
num=Len(s$)
For i=1 To hum
b$=______
If b$ = "a" Then x=x + 1
Next i
Print "x="; x
End Sub

我来回答:

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

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码