Cod sursa(job #143247)

Utilizator andrei-alphaAndrei-Bogdan Antonescu andrei-alpha Data 26 februarie 2008 08:45:16
Problema Algoritmul lui Euclid Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.39 kb
#include<stdio.h>
int main()
{int a,b,cmmdc;
freopen("euclid2.in", "r",stdin);
freopen("euclid2.out", "w",stdout);
scanf("%d%d",&a,&b);

if(a<4 || b<4) {cmmdc=1; printf("1"); return 0;} 
if( a==0 ) {cmmdc=b; printf("%d",cmmdc); return 0;} 
    while( b!=0 )
      {if( a>b )
           a=a-b;
       else
           b=b-a;
	  }
     cmmdc=a;
	printf("%d", cmmdc);
	 return 0;
}