Cod sursa(job #1268849)

Utilizator thewildnathNathan Wildenberg thewildnath Data 21 noiembrie 2014 16:06:51
Problema Deque Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.85 kb
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    // program to find out if the number is symetric    
    // we need n for number, temp for temporary value to keep n
    // and also a variable for divisor
    
    int n, temp, div=1, flag=0; 
    cout << "Please enter the number " << endl;
    cin >> n; 
    temp = n;   
    for ( ; temp != 0 ; ) 
    {
        div = div * 10;
        temp = temp/10;
    }        
    div = div/10;   
    for( ; div!=0 ; ) 
    {
         if( n/div != n%10 )
             flag=1;
         n = n/10; 
         div = div/10;
         if(div==0)
         break;
         n = n%div;
         div = div/10;
    }    
    if(flag==0)
        cout << "yes"<< endl;
    else
        cout << "no" << endl; 
    system("PAUSE");
    return EXIT_SUCCESS;
}