周训三 1196 去掉空格

1196 去掉空格

C语言网传送门

  • 题目描述
    读入一些字符串,将其中的空格去掉。

  • 输入
    输入为多行,每行为一个字符串,字符串只由字母、数字和空格组成,长度不超过80。输入以“End of file”结束。

  • 输出
    对于每行输入,输出转换后的字符串。

  • 样例输入
    Hello World
    1 2 3
    Nice to meet you
    abc

  • 样例输出
    HelloWorld
    123
    Nicetomeetyou
    abc

#include<stdio.h>
int main(void)
{
	int i;
	char c[80];
	while(scanf("%c",&c[0])!=EOF)
	{
		for(i=1;i<=79;i++){c[i]=-1;}
		for(i=1;i<=79;i++)
		{
			scanf("%c",&c[i]);
			if(c[i]=='\n')break;
		}
		for(i=0;i<=79;i++)
		{
			if(c[i]!=' '&&c[i]!='\n')printf("%c",c[i]);
			else if(c[i]=='\n')break;
		}printf("\n");
	}
	return 0;
} 
posted @ 2020-11-22 19:36  summeriver13  阅读(96)  评论(0)    收藏  举报