C语言求最大公约数

来源:互联网 发布:性格温柔的男生知乎 编辑:程序博客网 时间:2024/06/09 17:15
#include<stdio.h>int main(){    int n=0,temp=0,k=0,m=0;    printf("Enter two integers:");    scanf("%d%d",&n,&m);    if (n>m)    {        temp=n;        n=m;        m=temp;    }    while(n!=0)    {        k=m%n;        m=n;        n=k;    }    printf("Greatest common divisor:%d",m);    getch();}

 
原创粉丝点击