Advertisement
desislava_shunina

Task_2

Oct 23rd, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | Source Code | 0 0
  1. #include <iostream>
  2. int main() {
  3.     int a, b;
  4.     std::cin >> a >> b;
  5.     if (a > b) {
  6.         int c = a;
  7.         a = b;
  8.         b = c;
  9.     }
  10.     if (a == 0 || b == 0) {
  11.         std::cout << "Invalid input";
  12.     }
  13.     else {
  14.         for (int i = a; i >= 1; i--) {
  15.             if (a % i == 0 && b % i == 0) {
  16.                 std::cout << i << " ";
  17.             }
  18.         }
  19.     }
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement