Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. //============================================================================
  2. // Name        : HelloWorld.cpp
  3. // Author      : smalinux
  4. // Version     :
  5. // Copyright   : Your copyright notice
  6. // Description : Hello World in C++, Ansi-style
  7. //============================================================================
  8.  
  9. #include <iostream>
  10. #include <string>
  11. #include<iomanip>
  12. using namespace std;
  13.  
  14.  
  15.  
  16. int main() {
  17.     // ----------------------------------------------------------------------
  18.  
  19.     unsigned int N = 0;
  20.     int lowest = 0;
  21.     int lowestPositon = 0;
  22.     int arr[998];
  23.     cin >> N;
  24.  
  25.     // - Insertion
  26.     if(N >= 2 && N <= 1000) {
  27.         for(int i = 0; i < N; i++)
  28.             cin >> arr[i];
  29.  
  30.         // - Output
  31.         lowest = arr[0];
  32.         for(int i = 0; i < N; i++) {
  33.             if(arr[i] < lowest) {
  34.                 lowest          = arr[i];
  35.                 lowestPositon   = i;
  36.             }
  37.         }
  38.  
  39.         if(lowest >= -1e5 && lowest <= 1e5)
  40.             cout << lowest << " " << ++lowestPositon;
  41.     }
  42.  
  43.     // ----------------------------------------------------------------------
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement