#include <stdio.h>
int gcd_recursive(int a, int b) {
if (b == 0)
return a;
else
return gcd_recursive(b, a % b);
}
int gcd_iterative(int a, int b) {
while (b != 0) {
int temp = a % b;
a = b;
b = temp;
}
return a;
}
int main() {
int length, width;
printf("请输入土地的长度和宽度:\n");
scanf("%d%d", &length, &width);
int size_recursive = gcd_recursive(length, width);
printf("使用递归方法,农场主可以将土地分成边长为%d的方块\n", size_recursive);
int size_iterative = gcd_iterative(length, width);
printf("使用递推方法,农场主可以将土地分成边长为%d的方块\n", size_iterative);
return 0;
}