In number theory, the Euclidean algorithm (also called Euclid s algorithm) is an algorithm to determ

源代码在线查看: euclidean algorithm for gcd.cpp

软件大小: 9 K
上传用户: beixinning
关键词: algorithm Euclidean Euclid number
下载地址: 免注册下载 普通下载 VIP

相关代码

				// 436.cpp : Defines the entry point for the console application.
				//
				
				#include "stdafx.h"
				#include 
				int mod(int u,int v)
				{
					int t,r;
					if(u>v && v==0)
						return u;
					if(u						return v;
					else 
						if(v>u && u!=0)
					{
						t=u,u=v,v=t;
					}
					while((r=u%v)!=0)
					{
						u=v;
						v=r;
					}
					return (v);
				}
				
				
				int gcd(int m,int n)
				{   
					int mod(int x,int y);
					int l;
				    l=mod(m,n);
					return l;
					
				}
				
				int main()
				{
					int a,b,c;
					cin>>a>>b;
					if(a					{	
						cout					}
					else
						if(a==0 && b==0)
						{
							cout						}
							c=gcd(a,b);
							cout							return 0;
				}
				
				
							

相关资源