游客 Signup | Login
中文 | En

2476 - 分离句子 (2219)

小A学英语有个毛病,总喜欢把很多单词写在一行里,来帮小A分开来写,一行写一个单词,然后打印出来。输入一个句子(末尾有句号,每两个单词之间有一个空格),输出分离后的句子。

Input

输入一个句子(末尾有句号,每两个单词之间有一个空格)

Output

输出分离后的句子

Examples

Input

I am a boy.

Output

I
am
a
boy

Solution C

#include <stdio.h>
#include <stdlib.h>
#include "string.h"



int main()
{
	int i,j,start = 0,len,word_len = 0;
	char str[100];
	while(gets(str))
	{
		len = strlen(str);
		for(i = 0; i < len-1; i ++)
		{
			if(str[i] != ' ')
				printf("%c",str[i]);
			else
				printf("\n");
		}
		printf("\n");
	}
 
	return 0;	
}

Solution C++

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    char ch[10000];
    gets(ch);
    for(int i=0;ch[i]!='\0';i++)
    {
      if(ch[i]=='.')
      cout<<endl;            
      else if(ch[i]!=' ')
      cout<<ch[i];
      else
      cout<<endl;      
            }
   // system("PAUSE");
    return EXIT_SUCCESS;
}

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题