去掉空格

1106: 去掉空格

Time Limit: 1 Sec  Memory Limit: 128 MB

Description

读入一些字符串,将其中的空格去掉。

Input

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

Output

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

Sample Input

Hello World
1 2 3
Nice to meet you
abc

Sample Output

HelloWorld
123
Nicetomeetyou
abc

HINT

用scanf是不能读入一行有空格的字符串的,用gets吧。 用“gets(str) != NULL”可以判断输入是否结束,如果此条件为假(即gets(str) == NULL),则表示输入结束(对于本题)。

Source

吉首大学软件学院

 1 #include <stdio.h>
 2 int main()
 3 {
 4     char a[1000];
 5     while(gets(a))
 6     {
 7         for(int i=0;a[i]!='';i++)
 8         {
 9             if(a[i]==' ')
10                 continue;
11             else
12                 printf("%c",a[i]);
13         }
14         printf("
");
15     }
16     return 0;
17 }
原文地址:https://www.cnblogs.com/tianmin123/p/4738831.html