-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProArquis_KWIC.cpp
94 lines (76 loc) · 1.81 KB
/
ProArquis_KWIC.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Created by: ProArquis
* Martha Benavides A01280115
* Melissa Figueroa A01280388
* Pedro Esparza A01280126
* César de la Barreda A01195359
*
*/
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
/*
Ejemplo:
Entrada:
Clouds are white
Pittsburgh is beautiful
END
Salida:
are white clouds
beautiful pittsburgh is
clouds are white
is beautiful pittsburgh
pittsburgh is beautiful
white clouds are
*/
vector<string> glbVecSCircularIt;
string transLowerC(string sLine) {
for (int iI = 0; iI < sLine.size(); iI++) {
sLine[iI] = tolower(sLine[iI]);
}
return sLine;
}
string cricularShift(string sLine) {
int iFindSpace = sLine.find(' ');
if(iFindSpace != -1){
sLine = sLine.substr(iFindSpace + 1) + " " + sLine.substr(0, iFindSpace);
}
return sLine;
}
void getInput() {
string sLine;
getline(cin, sLine);
sLine = transLowerC(sLine);
// el input termina cuando escriba "end"
while(sLine!="end") {
int iContWords = 0;
for (int iI = 0; iI < sLine.size(); iI++) {
if (sLine[iI] == ' ')
iContWords++;
}
sLine = transLowerC(sLine);
iContWords++;
for (int iI = 0; iI < iContWords; iI ++) {
glbVecSCircularIt.push_back(sLine);
sLine = cricularShift(sLine);
}
getline(cin, sLine);
sLine = transLowerC(sLine);
}
}
void sortData() {
sort(glbVecSCircularIt.begin(), glbVecSCircularIt.end());
}
void printOutput() {
for (int iI = 0; iI < glbVecSCircularIt.size(); iI++){
cout<<glbVecSCircularIt[iI]<<endl;
}
}
int main() {
getInput();
sortData();
printOutput();
return 0;
}