gogoWebsite

48. Enter any positive integer and programmatically determine whether the number is a palindrome number (palindrome number refers to reading from left to right and reading from right to left, such as 12321)

Updated to 1 day ago
#include<iostream>
 using namespace std;

 int main()
 {
     int n,temp;
     int k=0;
     int a[20];
     cout<<"please input an number: "<<endl;
     cin>>n;

     for(int i=0;i<20;i++)// is used to separate each bit and store it in an array
     {
         if(n>=1)
         {
             temp=n%10;//The key steps of separation
             a[i]=temp;
             n=n/10;
             k++;// Counter, can you know how many bits there are in this number in total?
         }
     }

     for(int m=0;m<k;m++)//Judge whether this number is a palindrome number
     {
         if(a[m]!=a[k-m-1])
         {
             cout<<"This is not a palindrome number!"<<endl;
             return -1;//Breaking out of the loop
         }
     }
     //The inspection is completed, and it will be here only if the scripture is written.
     cout<<"This is the number of palindrome!"<<endl;

     return 0;
 }