View Code of Problem 50

#include<stdio.h>
main()
{
	int j=0,word=0;
	char str1[80],str2[80];
	gets(str1);				//scanf("%s",str1);就是错的,大概是含有空格
	for(int i=0;str1[i]!='\0';i++)
	{
		if(str1[i]>='0'&&str1[i]<='9')
		{
			if(word==1)
			{
				str2[j++]='*';
			}
			str2[j++]=str1[i];
			word=0;
		}
		else if(str1[i]==' ')
			word=1;
		else
			word=1;
	}
	str2[j]='\0';
	printf("%s\n",str2);//puts(str2);也可
}

Double click to view unformatted code.


Back to problem 50