Advertisement
Kolyach

Евклид

Dec 9th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     setlocale(LC_ALL, "russian");
  8.     cout << "Введите числа, НОД которых необходимо вычислить: ";
  9.     int a, b;
  10.     cin >> a >> b;
  11.     while (a != 0 && b != 0) {
  12.         if (a > b)
  13.             a = a % b;
  14.         else b = b % a;
  15.     }
  16.     cout << "НОД = " << a + b<<endl;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement