-
Notifications
You must be signed in to change notification settings - Fork 2
/
codebattle2.cpp
73 lines (60 loc) · 1.25 KB
/
codebattle2.cpp
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
63
64
65
66
67
68
69
70
71
72
#include <vector>
#include <string>
#include <sstream>
#include<iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include <cstdio>
#include<map>
#include<gawkapi.h>
#include<lastlog.h>
#include<sanitizer/asan_interface.h>
#include<math.h>
#include<algorithm>
#include<tr1/regex>
using namespace std;
int main()
{
int t;
cin>>t;
char c;
getchar();
while(t--)
{
//cin>>l;
string str;
vector<string>tokens;
getline(cin,str);
//cout<<str<<endl;
string buf; // Have a buffer string
stringstream ss(str); // Insert the string into a stream
// Create vector to hold our words
while (ss >> buf)
{
tokens.push_back(buf);
}
int s=tokens.size();
for(int i=0;i<tokens.size();i+=2)
{
if(s==1)
cout<<tokens[i];
else
cout<<tokens[i]<<" ";
}
for(int i=1;i<tokens.size();i+=2)
{
if(i==s-1||i==s-2)
cout<<tokens[i];
else
cout<<tokens[i]<<" ";
}
// for(int i=0;i<odd.size();i++)
// cout<<odd[i]<<" ";
// for(int i=0;i<even.size();i++)
// {
//
// cout<<even[i]<<" ";
// }
cout<<endl;
}
}