fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main() {
  4. int a[200], x, i, n;
  5. cin >> n;
  6. for (int i = 0; i < n;i++) {
  7. cin >> a[i];
  8. }
  9. cin >> x;
  10. for (int i = 0; i < n;i++) {
  11. if (a[i] == x) {
  12. cout << i;
  13. break;
  14. }
  15. else {
  16. cout << -1;
  17. break;
  18. }
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 5540KB
stdin
Standard input is empty
stdout
-1