Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <iostream>
- using namespace std;
- int licznik , mianownik ;
- void NWD ( int mianownik , int licznik ) ;
- int main()
- {
- cout << "Program, ktory skraca ulamek zwykly" << endl ;
- while ( mianownik == 0 )
- {
- cout << "Licznik = " ;
- cin >> licznik ;
- cout << endl ;
- cout << "Mianownik = " ;
- cin >> mianownik ;
- cout << endl ;
- if ( mianownik == 0 )
- {
- cout << "Nie mozesz dac zera w mianowniku. Sorka, ale taki klimat mamy!" << endl ;
- }
- }
- NWD ( mianownik , licznik ) ;
- return 0 ;
- }
- void NWD ( int mianownik, int licznik )
- {
- int x , y , z ;
- if ( mianownik < licznik )
- {
- x = licznik ;
- y = mianownik ;
- }
- else
- {
- x = mianownik ;
- y = licznik ;
- }
- do
- {
- z = x % y ;
- x = y ;
- y = z ;
- }
- while ( z != 0 ) ;
- cout << licznik << "/" << mianownik << " = " << licznik / x << "/" << mianownik / x << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement