160. 輾轉相除法
user_6817964
c_cpp
2 years ago
277 B
4
Indexable
int GCD(int t, int v) { if (t % v == 0) { return v; } else { GCD(v, t % v); } } int main() { int a, b; scanf("%d", &a); scanf("%d", &b); int temp; if (b > a) { temp = a; a = b; b = temp; } printf("%d\n", GCD(a, b)); return 0; }
Editor is loading...