Data_Structure/作業/unit5/gcd-indent.cpp
2025-01-20 21:30:53 +08:00

32 lines
403 B
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <stdlib.h>
void gcd(int a , int b ){
int temp , r;
r = a % b;
if(r!=0){
if(b>a){
temp = a;
a = b;
b = temp;
}
r = a % b;
printf("gcd(%d,%d)\n",a,b);
a = r;
gcd(a,b);
}else{
printf("gcd(%d,%d)\n",b,a);
printf("\nans = %d",b);
}
}
int main(){
int a , b ,ans;
printf("¿é¤J¨â­Ó¥¿¾ã¼Æ ==> ");
scanf("%d %d",&a,&b);
gcd(a,b);
return 0 ;
}