辗转相除法求最大公约数

来源:互联网 发布:editplus4怎么编程 编辑:程序博客网 时间:2024/05/07 22:16
#include <stdio.h>

int main()
{
int a,b;
int t;
scanf("%d %d", &a, &b);
int origa = a;
int origb = b;
while ( b != 0 ) {
t = a%b;
a = b;
b = t;
}
printf("%d和%d的最大公约数是%d.\n", origa, origb, a);
return 0;
}
0 0
原创粉丝点击