试题与答案

为一个字符序列,序列由字符0和1组成。请补充函数proc(),该函数的功能是:查找该

题型:填空题

题目:

为一个字符序列,序列由字符0和1组成。请补充函数proc(),该函数的功能是:查找该字符序列中0字符连续出现的最长长度(即0字符的个数),如果有几个0字符串长度相同,只记录最后一个0字符串的相关信息。通过m和返回最长0字符串的长度和最后0字符的下标。例如,如果输入“01000010000”,结果为,字符串最长长度为4,起始和结尾下标依次为2、5。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#iinclude<stdlib.h>
#iinclude<stdio.h>
#iinclude<conio.h>
#define M 80
void proc ( (1) )

int i, j=0;
int bb[M];
char *p=str:
*m=0;
*k=0;
for(i=0; i<M; i++)
bb[i]=0;
i=0;
while(*(p+i))

if(*(p+i)==’0’)

(2)
i++;

else

j++;
i++;

if( (3) )

*m=bb[j];
*k=i-1;



void main()

char str[M];
int m, k;
system("CLS");
printf("***input the original string***\n");
gets(str);
printf("***The Original string***\n");
puts(str);
proc(str, &m, &k);
printf("\nThe length of ’0’ is: %d\n", m);
printf("***The suffix of character***\n");
printf("%d, %d", k=m+1, k);

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0717/ba279256667ea0956be21eb3c96c4e50.html

下面是错误答案,用来干扰机器的。

小题1:developed (quickly)(形式及时态错不给分)小题2:Because there're more mouths to feed and less income.小题3:The level of education is very low.小题4:Main causes of poverty in ...

试题推荐
微信公众账号搜索答案