编写一个函数,由实参传来一个字符串,统计此字符串中字母、数字、空格和其他字符的个数,在主函数中输入字符串以及输出上述的结果。
输入两个字符串a,b,如果第一个字符串a中含有空格符,则用字符串b替换字符串a中的空格,否则保持a不变。最终得到替换后的新字符串c,并输出。要求: 1用gets函数得到从键盘输入的字符串; 2. 字符串a,b的长度最大为100,定义宏maxLength表示最大长度,新字符串c的最大长度为maxLength* maxLength 输入提示信息: "Input the first str:" "Input the second str:" 输出提示信息: "New str:" 输出格式:"%s" 程序运行示例1(有2个空格): Input the first str:abc 123 dd↙ Input the second str:YYY↙ New str:abcYYY123YYYdd 程序运行示例2(没有空格): Input the first str:abc↙ Input the second str:yy↙ New str:abc 程序运行示例3(有3个空格): Input the first str:abc 123↙ Input the second str:yy↙ New str:abcyyyyyy123
例如,str="abc3de987f9621",结果为:3987621。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。
试题程序:
include
define M 80
int bb[M];
int proc(char str[],int bb[],int num)
{
int i,n=0;
for(i=0;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
printf("%d",bb[i]);
}
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!