#include<stdio.h>
/*使用记录上一次输入的字符*/
/*方法一*/
int main()
{
int c=0;
char lastc='a';
while((c=getchar())!=EOF)
{
if(c!=' ')
putchar(c);
else if(c==' ')
{
if(lastc!=' ')
putchar(' ');
}
lastc=c;
}
}
/*方法二*/
#include<stdio.h>
int main()
{
int c=0;
char lastc='a';
while((c=getchar())!=EOF)
{
if(c!=' '||lastc!=' ') // 两次连续 其中有一次不为空 则输出
putchar(c);
lastc=c;
}
}