2025-03-06 22:46:33 +08:00

20 lines
439 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
编程用“碾转相除法”求两个整数的最大公约数,两个整数由键盘输入。(注使用while循环
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int m,n,t;
printf("请输入两个整数:");
scanf("%d%d",&m,&n);
t=m%n;
/**********Program**********/
while(t){
m = n;
n = t;
t = m%n;
}
/********** End **********/
printf("最大公约数是:%d\n",n);
}