问题:
求两个数的最大公约数。
//最大公约数
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int m, n, b;
int temp;
scanf("%d%d", &m, &n);
if(m<n)
{
temp = m;
m = n;
n = temp;
}
b = m % n;
while(b!=0)//辗转相除法
{
m = n;
n = b;
b = m % n;
}
printf("%d\n", n);
return 0;
}
/*
56 72
8
*/原文地址:http://blog.csdn.net/orangeisnotapple/article/details/44787331