Kiemr tra xem số có phải là số đảo ngược
Ex:
Input: 12345 54321
Output: Yes
Code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,m;
cin>>n>>m;
int b[100000],a[100000];
int x = 0 , z = 0;
while(n != 0)
{
int t = n % 10;
a[x++] = t;
n = n / 10;
}
while(m != 0)
{
int t = m % 10;
b[z++] = t;
m = m / 10;
}
for(int i = 0 ; i < x - 1 ; i++)
{
for(int j = i + 1 ; j < x ; j++)
{
if(a[i] > a[j])
{
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
int f = 0;
for(int i = 0 ; i < x ; i++)
{
for(int j = i ; j < i + 1 ; j++)
{
if(a[i] != b[j])
{
cout<<"No";
break;
}
if(a[i] == b[j])
f++;
}
}
if(f == x)
cout<<"Yes";
return 0;
}