#include <stdio.h> int main() { int num1,num2; printf("请输入两个整数:"); scanf("%d%d",&num1,&num2); while(num1%num2) { int r=num1%num2;//运用辗转相除法 num1=num2; num2=r; } printf("%d\n",num2); return 0; }
时间: 2024-12-26 19:23:27
#include <stdio.h> int main() { int num1,num2; printf("请输入两个整数:"); scanf("%d%d",&num1,&num2); while(num1%num2) { int r=num1%num2;//运用辗转相除法 num1=num2; num2=r; } printf("%d\n",num2); return 0; }