Jump to content

Recommended Posts

1. Cerinta:

Se dă un număr de la tastatură, să se verifice în altă funcție (Tip Void) dacă acesta este sau nu palindrom. Programul va returna "Da" sau "Nu" dacă acesta îndeplinește condiția.

 

2. Rezolvare:

#include <iostream>
using namespace std;


void palindrom(int n)
{
    int  ult, nrnou=0, m = n;
    while (n != 0)
    {
        ult = n % 10;
        nrnou = nrnou * 10 + ult;
        n = n / 10;
    }
    if (m == nrnou)
        cout << "Da";
    else
        cout << "Nu";

}

int main()
{
    int n;
    cin >> n;
    palindrom(n);
    system("Pause");
    return 0;
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Who's Online   0 Members, 0 Anonymous, 1 Guest (See full list)

    There are no registered users currently online

×

Important Information

This site uses cookies. By continuing browsing, you agree to the use of this information. For more details, see Terms of Use and Privacy Policy.