-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathA.cpp
39 lines (30 loc) · 838 Bytes
/
A.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
#include <bits/stdc++.h>
using namespace std;
bool is_palindrome(string w) {
for (int i = 0, j = w.size() - 1; i < w.size()/2; ++i, --j)
if (w[i] != w[j]) return false;
return true;
}
int main() {
int N;
cin >> N;
while(N--) {
char word[100], c;
vector<string> words;
string phrase = "";
while(scanf("%s%c", word, &c), words.push_back(word), phrase += word, c != '\n');
if (is_palindrome(phrase)) {
bool ok = true;
for(auto word: words) {
if (!is_palindrome(word)) {
ok = false;
break;
}
}
if (ok) cout << "Palindromo completo\n";
else cout << "Frase palindromo\n";
}
else cout << "Nada\n";
}
return 0;
}