Advertisement
zicaentu

НОД

Feb 21st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char const *argv[])
  4. {
  5.     int a, b;
  6.  
  7.     printf("Введите a и b:\n");
  8.     scanf("%d%d", &a ,&b);
  9.  
  10.     printf("НОД(%d, %d) = ", a, b);
  11.    
  12.     while(a != 0 && b != 0)
  13.         if(a > b) a %= b;
  14.         else      b %= a;
  15.    
  16.     printf("%d\n", a + b);
  17.  
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement