-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1244.cpp
More file actions
47 lines (35 loc) · 868 Bytes
/
1244.cpp
File metadata and controls
47 lines (35 loc) · 868 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
//presentation error
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
bool comp(string s1, string s2) {
return s1.size() > s2.size();
}
int main(){
int n;
cin >> n;
cin.ignore();
for(int i=0; i<n; i++){
vector<string> palavras;
vector<string> ordenado;
string linha;
string letra;
getline(cin, linha);
for(int j=0; j<=linha.size(); j++){
if(linha[j] == ' ' || j==linha.size()){
palavras.push_back(letra);
letra.clear();
} else {
letra += linha[j];
}
}
stable_sort(palavras.begin(), palavras.end(), comp);
for(auto palavra : palavras){
cout << palavra << " ";
}
cout << endl;
}
return 0;
}