作者在 2009-02-13 11:35:01 发布以下内容
/*Write a program to copy its input to its output,
*replacing each string of one or more blanks by a single blank*/
#include <stdio.h>
*replacing each string of one or more blanks by a single blank*/
#include <stdio.h>
#define OUT 1 /* outside the word */
#define IN 0 /* inside the word */
#define IN 0 /* inside the word */
int main(void)
{
int c,state;
state = OUT;
while ((c = getchar()) != EOF)
{
if (state == OUT && c == ' ')
{
state= IN;
putchar(c);
}
else if (c != ' ')
{
putchar(c);
state = OUT;
}
else
;
}
return 0;
}
{
int c,state;
state = OUT;
while ((c = getchar()) != EOF)
{
if (state == OUT && c == ' ')
{
state= IN;
putchar(c);
}
else if (c != ' ')
{
putchar(c);
state = OUT;
}
else
;
}
return 0;
}