1 //辗转相除 2 int function(int a, int b) 3 { 4 int temp; 5 if(a > b) 6 { 7 temp = a; 8 a = b; 9 b = temp; 10 } 11 if(a % b = 0) 12 { 13 return b; 14 } 15 else 16 { 17 return function(b, a % b); 18 } 19 }
1 //辗转相除 2 int function(int a, int b) 3 { 4 int temp; 5 if(a > b) 6 { 7 temp = a; 8 a = b; 9 b = temp; 10 } 11 if(a % b = 0) 12 { 13 return b; 14 } 15 else 16 { 17 return function(b, a % b); 18 } 19 }