fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6. int N = 5;
  7. int arr[5] = {3, 5, 8, 15, 19};
  8. int i = 0;
  9. int x = 18;
  10.  
  11. while(i < N-1){
  12. if(arr[i] < x && arr[i+1] >= x){
  13. cout << i+1;
  14. }
  15. i++;
  16. }
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
4