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

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

str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数proc,该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。

例如,str="abc3de987f9621",结果为:3987621。

注意:部分源程序给出如下。

请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。

试题程序:

include<stdio.h>

define M 80

int bb[M];

int proc(char str[],int bb[],int num)

{

int i,n=0;

for(i=0;i<num;i++)

{

if(【1】)

{

bb[n]=【2】:

n++:

}

}

return 【3】 ;

}

void main

{

char str[M];

int mum=0,n,i;

printf("Enter a strin9:\n");

gets(str);

while(str[num])

num++:

n=proc(str,bb,num);

printf("\nbb=");

for(i=0;i<n;i++)

printf("%d",bb[i]);

}


参考答案

更多 “ str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数proc,该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。例如,str=abc3de987f9621,结果为:3987621。注意:部分源程序给出如下。请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。试题程序:includestdio.hdefine M 80int 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 mum=0,n,i;printf(Enter a strin9:\n);gets(str);while(str[num])num++:n=proc(str,bb,num);printf(\nbb=);for(i=0;in;i++)printf(%d,bb[i]);} ” 相关考题
考题 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]); }

考题 假定输入的字符串中只包含字母和*号。请编写函数proc,它的功能是:将字符串中的前导*号全部删除,中间和后面的*号不删除。例如,若字符串中的内容为****a*bc*def*g** **,删除后,字符串中的内容则应当是a*bc*def*g** **。注意:部分源程序给出如下。请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填入所编写的若干语句。试题程序:includestdio.h=:{includeconio.hwoid proc(char*st r){}void mainchar str[81];printf("Enter a string:\n");gets(str);proc(str):printf("The string after deleted:\n");puts(str);}

考题 假定输人的字符串中只包含字母和*号。请编写函数proc,它的功能是:将字符串中 的前导*号全部删除,中间和后面的*号不删除。 例如,若字符串中的内容为****a*bc*def*g****,删除后,字符串中的内容则 应当是a*bc*def*g****。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填入所编 写的若干语句。 试题程序: includestdio.h includeconio.h void proc(char*str) { } void main { char str[81]; printf("Enter a string:kn"); gets(str); proc(str); printf("The string after deleted:kn"); puts(str);}

考题 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]);}

考题 请编写一个函数fun(),该函数的功能是:返回给定字符串中大写字母字符的个数。如字符串"Hello World"中,大写字母的个数为2个。注意:部分源程序已存在文件PROC5.CPP中。请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句。文件PROC5.cpp的内容如下://PROC5.cppinclude<iostream>include<string>using namespace std;int fun(char *str);int main(){char str[ ]="Chinese Computer World";cout<<fun(str)<<end;return 0;}int fun(char *str){//**********}

考题 str是全部由小写字母字符和空格字符组成的字符串,由 num传入字符串的长度。请补充函数fun(),该函数的功能是:统计字符串str中的单词个数,结果由变量num传回。每个单词之间都由空格隔开,并且字符串str开始不存在空格。例如:str=“how do you do”,结果为:num=4。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun(char *s,int *num){int i,n=0;for(i=0;【 】;i++){if(s[i]>='a',s[i]<='z',(s[i+1)==’’||s[i+1]=='\0'))【 】;}【 】;}main(){char str[N];int num=0;printf("Enter a string:\n");gets(str);while(str[num])num++;fun(str,num);printf("The number of word is:%d\n\n",num);

考题 函数fun的功能是将一个数字字符串转换为一个整数,请将函数补充完整。int fun(char*str){int hum=0;while(*str){num*=10;num+=______str++;}return num;}

考题 请补充函数proc(),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。例如,str1=”I am a”,str2=”student”,结果输出:I am a student。注意:部分源程序给出如下。请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。试题程序:

考题 请补充函数proc(),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码升序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传人。例如,如果输入“9fedcba”,则输出为“abcdefg”。注意:部分源程序给出如下。请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。试题程序: