Advertisement
Radostin05

Untitled

Nov 18th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | Source Code | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int x;
  6.     cin>>x;
  7.     int y;
  8.     cin>>y;
  9.     int z;
  10.     cin>>z;
  11.     int gcd;
  12.  
  13.  
  14.  
  15.     for (int i = 1; i <=x && i<=y && i<=z; ++i) {
  16.         if (x%i==0 && y%i==0 && z%i==0) {
  17.             gcd = i;
  18.         }
  19.     }
  20.     if (x<20 ||x>300 || y<20 || y>300 || z<20 || z>300) {
  21.         cout<<"Invalid input data!"<<endl;
  22.     }else {
  23.         cout<<gcd<<endl;
  24.     }
  25.     return 0;
  26. }
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement