Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- int m=0,n=0,dzielnik=0,r=0;
- printf("Podaj liczby: \n");
- scanf("%d",&m);
- scanf("%d",&n);
- // A
- while(m!=n)
- {
- if(m>n)
- {
- m=m-n;
- dzielnik=m;
- }
- else
- {
- n=n-m;
- dzielnik=n;
- }
- }
- // B
- /*
- do
- {
- r=m%n;
- if(r==0)
- {
- dzielnik=n;
- }
- m=n;
- n=r;
- }
- while(r!=0);
- */
- printf("NWD wynosi %d",dzielnik);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement