#2868
code
av_timer 3 ms
memory 256 KiB
access_time 2018-01-21 21:10:55
face jackpearson
#include <stdio.h>
#include <stdlib.h>


int substitute(char str[], char oldchar, char newchar);

int main(){
	char str1[1000];
	char a1,a2;
	int count;
	while(scanf("%s %c %c",str1,&a1,&a2)==3)
	{
	//处理字符串
	count=substitute(str1,a1,a2);
		printf("%d ",count);
		printf("%s\n",str1);
	}
}


int substitute(char str[], char oldchar, char newchar)
{	int i=0,count=0;
while(str[i]!=EOF)
{
	if(str[i]==oldchar)
	{count++;str[i]=newchar;}
	i++;
}
return count;
}