1009 说反话,C

#include <stdio.h>

int main()
{
	char a[100] = {0};
	char b[100] = {0};
	int i=0,j=0,k=0,c=0;

	scanf("%[^\n]",a);//特别注意,不能用"%s",不然一接收到空格就停止了
	
	while( 1 )
	{
		while(a[j] != 32 && a[j])
			j++;
		c = j;
		j--;
		while(j != i-1)
		{
			b[k] = a[j];
			j--;
			k++;
		}
		b[k] = a[c];	k++;	
		j = c+1;
		i = c+1;
		
		if( a[c]==0 )	break;
	}
	
	k = k-2;
	while( k+1 )
	{
		printf("%c",b[k]);
		k--;
	}

	system("pause");
}
发布了44 篇原创文章 · 获赞 0 · 访问量 895

猜你喜欢

转载自blog.csdn.net/weixin_43916400/article/details/104355902
今日推荐