pat1009:说反话

https://www.patest.cn/contests/pat-b-practise/1009

#include "stdio.h"
#include "string.h"

int main()
{
	int i, len, k, j = 0, a[80] = {0};
	char str[81];
	gets(str);
	len = strlen(str);
	for(i = 0; i < len; ++i)
		if(' ' == str[i]) 
			a[j++] = i;
	k = j;
	for(j = k-1; j >= 0; )
	{
		for(i = a[j]+1; (i < len) && (' ' != str[i]); ++i)
			printf("%c", str[i]);
		--j;
		printf(" ");
	}
	for(i = 0; ' ' != str[i] ;++i)
		printf("%c", str[i]);
	printf("\n");

	return 0;
}


你可能感兴趣的:(c,pat)