#include <iostream.h>
int a1,a2,b1,b2,c1,c2,n1,n2,ivzp,t;
void nod2(int a2,int a1,int b2,int b1, int &n2,int &n1,int &ivzp) {
ivzp=0;
et1: if ( (a2==b2) && (a1==b1) ) goto et10;
if (a2>b2) goto et2;
if ( a2==b2 && a1>b1 ) goto et2;
c1=b1 ;
c2=b2;
b1=a1;
b2=a2;
a1=c1;
a2=c2;
et2: a1=a1-b1;
if (a1<0)
{
a1=a1+10000;
a2=a2-1;
}
a2=a2-b2; goto et1;
et10 : n1=a1; n2=a2 ;
if ( (n1==1) && (n2==0) )
{
ivzp=1;
}
}
void main()
{
cout<<"\n"<<"vavedete A2= "; cin>>a2;
cout<<"\n"<<"vavedete A1= "; cin>>a1;
cout<<"\n"<<"vavedete B2= "; cin>>b2;
cout<<"\n"<<"vavedete B1= "; cin>>b1;
nod2(a2,a1,b2,b1,n2,n1,ivzp) ;
cout<<" NOD="<<n2<<" "<<n1<<" IVZP= "<<ivzp;
}
No comments:
Post a Comment