fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. const int maxsize = 100000;
  6.  
  7. int main()
  8. {
  9.  
  10. int iteration = 0; // Number Of Iteration in loops.
  11. int elements[maxsize]; // Elements to enter.
  12. int outArr[maxsize]; // To Perform A Operation On the output.
  13. int flag = 0; // Flag to find value.
  14. int temp = 0; // Temp to test the values in arrays.
  15.  
  16. cin >> iteration;
  17.  
  18. if (iteration >= 1 && iteration <= 10000) // Number Of Iteration Checking.
  19. {
  20. for (int i = 0; i < iteration; i++) // Iteration to get values.
  21. {
  22. cin >> elements[i];
  23. }
  24.  
  25. cin >> temp;
  26.  
  27. for (int i = 0; i < iteration; i++) // Loop to perform operation.
  28. {
  29. if (elements[i] == temp)
  30. {
  31. flag = i;
  32. break;
  33. }
  34. else
  35. flag = 0;
  36. }
  37.  
  38. if (flag == 0)
  39. cout << -1;
  40. else
  41. cout << flag;
  42. }
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0s 4284KB
stdin
Standard input is empty
stdout
Standard output is empty