Advertisement
Josif_tepe

Untitled

Oct 12th, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. int main() {
  5.     int n;
  6.     cin >> n;
  7.    
  8.     int niza[n];
  9.     for(int i = 0; i < n; i++) {
  10.         cin >> niza[i];
  11.     }
  12.     sort(niza, niza + n);
  13.     int x;
  14.     cin >> x;
  15.    
  16.     int idx = lower_bound(niza, niza + n, x) - niza;
  17.    
  18.     if(idx >= 0 and idx < n) {
  19.         cout << "Indeksot e " << idx << endl;
  20.     }
  21.     else {
  22.         cout << "Ne postoi takov broj" << endl;
  23.     }
  24.    
  25.  
  26.    
  27.     return 0;
  28. }
  29.  // 972
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement