-
Notifications
You must be signed in to change notification settings - Fork 9
/
reorder_rhymes.cpp
executable file
·58 lines (45 loc) · 996 Bytes
/
reorder_rhymes.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
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main(){
vector<string> rhymes;
int number_rhyme=0;
string s;
while(getline(cin,s)){
rhymes.push_back(s);
number_rhyme++;
}
//cout<<number_rhyme<<endl;
//swap 0,number_rhyme-2
//swap 1,number_rhyme-1
string t="";
t=rhymes[0];
rhymes[0]=rhymes[number_rhyme-2];
rhymes[number_rhyme-2]=t;
t=rhymes[1];
rhymes[1]=rhymes[number_rhyme-1];
rhymes[number_rhyme-1]=t;
if(number_rhyme==2){
cout<<rhymes[0]<<endl;
cout<<rhymes[1]<<endl;
return 0;
}
for(int i=0;i<min(number_rhyme,12);i++){
if(i%4==0)
cout<<rhymes[i]<<endl;
else if(i%4==1)
cout<<rhymes[i+1]<<endl;
else if(i%4==2)
cout<<rhymes[i-1]<<endl;
else
cout<<rhymes[i]<<endl;
}
if(number_rhyme==14){
cout<<rhymes[12]<<endl;
cout<<rhymes[13]<<endl;
}
return 0;
}