fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 500000;
  5.  
  6. int main() {
  7. int n, arr[MAX_SIZE + 1];
  8. cin >> n;
  9. for (int i = 1; i <= n; ++i) {
  10. cin >> arr[i];
  11. }
  12. int m;
  13. cin >> m;
  14. int x;
  15. for (int j = 1; j <= m; ++j) {
  16. cin >> x;
  17. int position = -1;
  18. for (int k = 1; k <= n; ++k) {
  19. if (arr[k] == x && position == -1) {
  20. position = k ;
  21. }
  22. }
  23. cout << position << " ";
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5284KB
stdin
10
1 2 3 4 4 4 5 6 6 7
4
2 4 5 6
stdout
2 4 7 8