code[vs] 1205 单词翻转

题目描述 Description

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

输入描述 Input Description

输入包括一个英语句子。

输出描述 Output Description

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

样例输入 Sample Input

I love you

样例输出 Sample Output

you love I

数据范围及提示 Data Size & Hint

简单的字符串操作

我真的是太不擅长字符串了。。

关于字符串的操作也太多了吧。。。

ac代码

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<algorithm>
 5 #include<cstring>
 6 using namespace std;
 7 
 8 string a[102];
 9 int i;
10 
11 int main()
12 {
13     while(cin>>a[i])
14     {
15         ++i;
16     }
17     for(int j=i-1;j>=0;--j)
18         cout<<a[j]<<" ";
19     return 0;
20 }

猜你喜欢

转载自www.cnblogs.com/Mary-Sue/p/9137913.html
今日推荐