1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need some help about reversing numbers

Discussion in 'C++' started by gotto, Jun 1, 2010.

  1. gotto

    gotto New Member

    Joined:
    Jun 1, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hello!
    I've begun programming on Dev C++ and I need some help. The input should be like 123 and the output 321. How can I make this? I don't understand it much right now... This is my code so far:
    #include<iostream.h>
    int main ()
    {
    int n,k,a,b,c;
    cin >> n >> k;
    a=n/100;
    b=n/10%10;
    c=n%10;
    if ((a+b+c)%k==0)
    cout << "yes" << " " << c,b,a << endl;
    else cout << "no" << " " << (a+b+c)*k << endl;
    system ("PAUSE");
    return 0;
    }
     
  2. gotto

    gotto New Member

    Joined:
    Jun 1, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Nevermind, I got it.
     

Share This Page