기본(Basic)

숫자 - 펠린드롬(Palindrome) 인지 확인 하기

cepiloth 2021. 1. 6. 12:46
반응형
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
//#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define MAX_SIZE 100
#define INF 0x7fffffff
 
using namespace std;
 
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, -1, 1};
 
int reverse(int x) {
    int rev = 0;
    while(x != 0){
        rev = rev*10 + x%10;
        x = x/10;
    }
    return rev;
}
 
int main() {
 
    int n; cin  >> n;
 
     if (n == reverse(n)) {
        cout << "Ok" << "\n";
     } else {
        cout << "No" << "\n";
    }
    return 0;
}
반응형