ver.1 ¶
if(x1 < x2) // 이 부분이 꼭 필요하지 않다고 문득 느낌..
{
int temp;
temp = x1;
x1 = x2;
x1 = temp;
}temp = x1;
x1 = x2;
x1 = temp;
ver.2 ¶
면 ver.1 .
못 변 print ..
는 를 .
못 변 print ..
- 부 x,y 린 는 방, 리
는 를 .
ver.1 ¶
~cpp #include <stdio.h> void main() { int x2, y2, x, y,remainder; printf(" (ex| 5 6):"); scanf("%d %d", &x, &y); x2 = x; y2 = y; //y y2를 . if(y2 < x2) { int temp; temp = x2; x2 = y2; x2 = temp; } // 리 while(y2 != 0){ remainder = x2 % y2; // x2= . y2= 는 . remainder= 머. x2 = y2; y2 = remainder; } printf("x = %d, y = %d\n GCD is %d", x, y, x2); }
ver.2 ¶
~cpp #include <stdio.h> void Eu_clidian(int x, int y); void main() { int x, y; printf(" (ex| 5 6):"); scanf("%d %d", &x, &y); Eu_clidian(x, y); } void Eu_clidian(int x, int y) { int x2, y2, remainder; x2 = x; y2 = y; while(y2 != 0){ // 리 remainder = x2 % y2; x2 = y2; y2 = remainder; } printf("The GCD of %d and %d is %d\n", x, y, x2); }