Advertisement
smatskevich

Min

Feb 27th, 2021
855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main() {
  4.   int n = 0;
  5.   std::cin >> n;
  6.  
  7.   if (n <= 0) {
  8.     std::cout << "ERROR: An array is empty.";
  9.     return 0;
  10.   }
  11.  
  12.   int x = 0;
  13.   std::cin >> x;
  14.   int cur_min = x;
  15.   for (int i = 1; i < n; ++i) {
  16.     std::cin >> x;
  17.     if (x < cur_min) cur_min = x;
  18.   }
  19.   std::cout << cur_min;
  20.   return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement