-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecoding_the_message.cpp
More file actions
55 lines (49 loc) · 985 Bytes
/
Decoding_the_message.cpp
File metadata and controls
55 lines (49 loc) · 985 Bytes
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
#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef vector<string> v ;
/*
string str{"the quick brown fox jumps over the lazy dog"};
vector<string> v{explode(str, ' ')};
for(auto n:v) cout << n << endl;
*/
const vector<string> explode(const string& s, const char& c)
{
string buff{""};
vector<string> v;
for(auto n:s)
{
if(n != c) buff+=n; else
if(n == c && buff != "") { v.push_back(buff); buff = ""; }
}
if(buff != "") v.push_back(buff);
return v;
}
int main()
{
int tc , c = 1 ;
cin>>tc;
string msg;
while(tc--)
{
cout<<"Case #"<<c<<":"<<endl;
while(getline(std::cin,msg))
{
if(msg.length()!=0)
break;
v arr= {explode(msg,' ')};
int i = 0 ;
for(auto x = arr.begin() ; x!=arr.end() ; ++x)
{
string str = *x ;
if(str.length()>i)
cout<<str[i++];
}
cout<<endl;
}
c++;
cout<<endl<<endl;
}
return 0;
}