您的位置:首页 > 编程语言 > C语言/C++

(C小程序)用C语言求  最大公约数…

2014-01-26 15:59 295 查看
#include "iostream.h"

#include "stdio.h"

void  MaxGY(int &m , int
&n) 

{   int 
temp,max,min;

   
if(m<n)

      
{

         
min = m;

         
max = n;

      
}

    else

      
{

         
min = n;

         
max =
m;            

      
}

     
temp=
max%min;   

  

   while(temp!=0)

     
{    

            
max = min;

 

            
min = temp;

            
temp= max%min;

       
}

    
cout<<min<<endl;

}

 

void main(void)

{

   
int  a ,b;

 
 cin>>a>>b;

   MaxGY(a, b) ;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: