اعداد متقارن اعدادی هستند که از هر طرف خوانده شود یکی هست.(مثال : 55555 12321 45554 11611) برنامه ای بنویسید که تعیین کند عدد وارد شده اول هست یا خیر؟
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int number, firstDigit, secondDigit, fourthDigit, fifthDigit;
cout << "Enter a five-digit number: ";
cin >> number;
firstDigit = number / 10000;
secondDigit = number % 10000 / 1000;
fourthDigit = number % 10000 % 1000 % 100 / 10;
fifthDigit = number % 10000 % 1000 % 10;
if(firstDigit == fifthDigit && secondDigit == fourthDigit)
cout << number << " is a palindrome" << endl;
else
cout << number << " is not a palindrome" << endl;
getch();
return 0;
}