how to write palindrome form of a number in c++ code example

Example 1: how to print nth palindrome number in c++

if(n <=1000 && i==0){
               // cout << " here "<<endl;
                count =0;
                i=0;
               // break;
                
            }else if( n >1000 && n <=2000 && i==0){
                //cout << "there " <<endl;
                count =1000;
                i=90109;
               // break;
            }else if( n >2000 && n <=2500 && i==0){
                //cout << "there " <<endl;
                count =2000;
                i=1001001;
                // break;
            }else if( n >2500 && n <=3000 && i==0){
                //cout << "there " <<endl;
                count =2500;
                i=1501051;
                // break;

Example 2: how to print nth palindrome number in c++

int n;
    int count =0;
    while(true){
        cin>> n;
        if (n == 0) return 0;
        
        if( n <= 10000){
        for( int i=1 ; i <= 2000000000; i++){

                if( palindrom(i) == true) {
                    count++;
                    //cout << "palindrom : " << i<< " count : " << count <<endl;
                
                
                    if( count == n ) {
                    
                        cout << i <<endl;
                   
                        count =0;
                        break;
                    }

Tags:

Cpp Example