求两个数的最大公约数:用辗转相除法
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main()
{
int num1 = 0;
int num2 = 0;
scanf_s("%d%d", &num1, &num2);
while (num1%num2)
{
int r = num1%num2;
num1 = num2;
num2 = r;
}
printf("%d\n", num2);
system("pause");
return 0;
}
本文出自 “Stand out or Get out” 博客,转载请与作者联系!
原文地址:http://jiazhenzhen.blog.51cto.com/10781724/1709774