#include<iostream>
using namespace std;
int main()
{
int a, b, nwd;
cout<<"Podaj liczbe a: ";
cin>>a;
cout<<"Podaj liczbe b: ";
cin>>b;
while(a!=b)
if(a>b)
a = a - b;
}
else
b = b - a;
nwd = a;
cout<<"NWD wynosi: "<<nwd<<endl;
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
#include<iostream>
using namespace std;
int main()
{
int a, b, nwd;
cout<<"Podaj liczbe a: ";
cin>>a;
cout<<"Podaj liczbe b: ";
cin>>b;
while(a!=b)
{
if(a>b)
{
a = a - b;
}
else
{
b = b - a;
}
}
nwd = a;
cout<<"NWD wynosi: "<<nwd<<endl;
}