ALDS1_1_B: Greatest Common Divisor

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B
最大公約数を求める問題。
教科書通り実装。

#include<stdio.h>


 int gcd ( int a, int b ){
int c;
while ( a != 0 ) {
 		c = a; a = b%a;  b = c;
}
return b;
 }
int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	printf("%d\n",gcd(x,y));
}
最終更新:2016年03月24日 02:12