fork(1) download
  1. #include <stdio.h>
  2. int euclid( int, int );
  3.  
  4. int main()
  5. {
  6. int m=0,n=0,answer;
  7. printf("2つの正の整数を 「m,n」 の様に入力:\n");
  8. scanf("%d,%d" , &m,&n);
  9. if(m<n){
  10. int tmp=m;
  11. m =n;
  12. n=tmp;
  13. }
  14. answer = euclid(m,n);
  15. printf( "%d,%d の最大公約数は %d です\n",m,n,answer);
  16. }
  17.  
  18. int euclid( int x, int y )
  19. {
  20. int r =x%y;
  21. if(r==0)
  22. return y;
  23. else
  24. return euclid(y,r);
  25. }
  26.  
Success #stdin #stdout 0.01s 5320KB
stdin
371,265
stdout
2つの正の整数を 「m,n」 の様に入力:
371,265 の最大公約数は 53 です