Advertisement
JosepRivaille

P74859: I-èssim (4)

Apr 9th, 2015
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6.     int i, x;
  7.     while (cin >> i) {
  8.         bool trobat = false;
  9.         int aux = i;
  10.         x = 0;
  11.         while (not trobat && i != 0 && x != -1) {
  12.             cin >> x;
  13.             if (x != -1) {
  14.                 --i;
  15.                 if (i == 0) trobat = true;
  16.             }
  17.         }
  18.         if (trobat) cout << "A la posicio " << aux << " hi ha un " << x << '.' << endl;
  19.         else cout << "Posicio incorrecta." << endl;
  20.         while (x != -1) cin >> x;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement