求两个数的最大公约数

来源:互联网 发布:腾讯内测手游软件 编辑:程序博客网 时间:2024/06/16 16:52
#include <stdio.h>int main(){    int a,b,r;    scanf("%d%d",&a,&b);    if(a<b)    {        r=a;        a=b;        b=r;    }    while(b!=0)    {        r=a%b;        a=b;        b=r;    }    printf("%d\n",a);    return 0;}

运行结果:
这里写图片描述

原创粉丝点击