码迷,mamicode.com
首页 > 其他好文 > 详细

1009. 说反话 (20)

时间:2017-03-19 15:44:41      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:编写   namespace   nbsp   name   com   using   没有   hello   测试   

1009. 说反话 (20)

给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。

输入格式:测试输入包含一个测试用例,在一行内给出总长度不超过80的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用1个空格分开,输入保证句子末尾没有多余的空格。

输出格式:每个测试用例的输出占一行,输出倒序后的句子。

输入样例:

Hello World Here I Come

输出样例:

Come I Here World Hello

注意:在VS中可能无法运行成功,因为VS判断文件结束需要手动输入ctrl+z
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

int main()
{
    char str[100][50];
    int i = 0, j;
    while (scanf("%s", &str[i]) != EOF)
    {
        i++;
    }
    for (i = i - 1; i > 0; i--)
    {
        printf("%s ", str[i]);
    }
    printf("%s\n", str[0]);
    return 0;
}

 

1009. 说反话 (20)

标签:编写   namespace   nbsp   name   com   using   没有   hello   测试   

原文地址:http://www.cnblogs.com/brightz2017/p/6580461.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!