Gửi bài giải
Điểm:
10,00
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Dạng bài
Panlindrom Chuỗi A gọi là panlindrom nếu như đọc xuôi A hay đọc ngược A cũng giống nhau. Ví dụ madam là panlindrom. Nhiệm vụ của bạn là kiểm tra chuỗi A có phải là panlindrom hay không? Đầu vào: Chuỗi A. Đầu ra: YES hoặc NO
INPUT madam OUTPUT YES INPUT bachcuong OUTPUT NO
Bình luận
void Solve(){ str s; getline(cin,s); str tmp = s; reverse(tmp.begin(), tmp.end()); if(tmp==s) cout << "YES\n"; else cout << "NO\n"; } int main(){ // iosbase :: syncwithstdio(0); cin.tie(0); cout.tie(0); // #ifndef ONLINEJUDGE // freopen("S.inp", "r", stdin); // #endif // freopen("S.out", "w", stdout); Solve(); }
include <iostream>
include <algorithm>
using namespace std;
int main() { string s; getline(cin, s); string t = s; reverse(t.begin(), t.end()); if (t==s){ cout<<"YES"; } else{ cout<<"NO"; }
}