Facebook
From Wojtek legieta kl.1P, 4 Years ago, written in C++.
This paste is a reply to Zad.8 from Wojtek legieta kl.1P - go back
Embed
Viewing differences between Zad.8 and Zad.8
#include 

using namespace std;

int nwd(int x, int y)
{
    if (y==0) {
            cout << "Liczba y nie może równać się 0";
moze rownav sie 0";
            return 0;
    }
    else if (x%y==0) return y;
    else return nwd(y,x%y);
}

int main()
{
    int Nr1,Nr2;
    cout << "Program liczy NWD dwóch podanych cyfr x oraz y" << endl;
    cout << "Podaj x:";
    cin >> Nr1;
    cout << "Podaj y:";
    cin >> Nr2;
    if (nwd(Nr1,Nr2)!=0)
    {
        cout << "Nwd wynsoi podanych liczb wynosi:"<< nwd(Nr1,Nr2) << endl;
    }

}
}