Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /* Napisz program, który pobiera od użytkownika dwie liczby naturalne, a następnie wypisuje na ekran ich największy wspólny dzielnik */
- int main()
- {
- int x, y, nwd = 1;
- cout << "Podaj dwie liczby naturalne: ";
- cin >> x >> y;
- for(int i = 2; i <= x; ++i)
- {
- if(x % i == 0 && y % i == 0)
- nwd = i;
- }
- cout << "Najwiekszy wspolny dzielnik liczb " << x << " i " << y << " wynosi " << nwd << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement