forked from YashviP/Competitive-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverseWords.cpp
More file actions
62 lines (56 loc) · 1.22 KB
/
Copy pathreverseWords.cpp
File metadata and controls
62 lines (56 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
Reverse Words
Code Jam
Esteban Arango Medina
*/
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
int main(){
freopen("B-small-practice.in", "r", stdin);
freopen("reverseWords.out", "w", stdout);
string s;
int n,cases=1;scanf("%d",&n);
getline(cin,s);
while(n--){
size_t found;
vector<string> words;
getline(cin,s);
printf("Case #%d: ",cases++);
found = s.find(" ");
while(found!=string::npos){
//cout<<found<<" "<<s<<endl;
words.push_back(s.substr (0,found));
s=s.substr(found+1,(s.length()-1));
found = s.find(" ");
}
words.push_back(s);
for (int i = words.size()-1; i >=0 ; --i)
{
cout<<words[i];
if(i-1>=0)
cout<<" ";
}
if(n)
cout<<endl;
}
return 0;
}