Codevs 1205 单词反转(Vector以及如何输出string)

时间:2024-08-03 08:36:38

题意:倒序输出句子中的单词

代码:

#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<vector>
#include<map> //#pragma GCC optimize(2) typedef long long ll;
using namespace std;
const int maxn = 10000 + 100;
const double eps = 1e-8; int main(){
vector<string>a;
char s[maxn];
int p = 0;
while(~scanf("%s", s)){
a.push_back(s); }
int n = a.size();
for(int i = n-1; i >= 0; i--){
printf("%s ", a[i].c_str());
} return 0;
}