csansoon

P6.09 P27411 I-th (2)

Nov 7th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int pos,n;
  6.     cin>>pos;
  7.     int pos2=1;
  8.     while (cin>>n&&pos2!=pos&&n!=(-1)) pos2++;
  9.     if (pos2<pos||pos<0||n==-1) cout<<"Incorrect position."<<endl;
  10.     else cout << "At the position "<<pos<<" there is a(n) "<<n<<"."<<endl;
  11. }
Add Comment
Please, Sign In to add comment