Codevs 1205 单词翻转

时间限制: 1 s
 空间限制: 128000 KB
 题目等级 : 青铜 Bronze
 
 
 
题目描述 Description

给出一个英语句子,希望你把句子里的单词顺序都翻转过来

输入描述 Input Description

输入包括一个英语句子。

输出描述 Output Description

按单词的顺序把单词倒序输出

样例输入 Sample Input

I love you

样例输出 Sample Output

you love I

数据范围及提示 Data Size & Hint

简单的字符串操作

代码:

#include <iostream>
#include <cstdio>
using namespace std;
void Write()
{
    char str[256];
    if (cin >> str)
        Write();
    else
        return ;
    printf("%s ",str);
}

int main()
{
    Write();
    return 0;
}

思路: 递归 处理  把每个单词当做一个字符串来处理  直接调递归

posted @ 2016-09-03 17:43  浮华的终成空  阅读(149)  评论(0编辑  收藏  举报

Contact with me