PTA(Basic Level) 1009:较简便的c语言实现

## PAT (Basic Level) Practice题解 1009 说反话 [C语言实现]

代码如下


利用了getchar()和scanf对空格输入的差异直接将单词分别存储至数组。然后倒序输出即可。

#include<stdio.h>
int main()
{
	char b[20][20];
	int i=0,j;
	while(1)
	{
		scanf("%s",b[i]);
		i++;
		if(getchar()=='\n') break;
	}
	for(j=i;j>1;j--)
	{
		printf("%s ",b[j-1]);
		
	}
	printf("%s",b[j-1]);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/lvgyf/article/details/108468400
今日推荐