csansoon

P6.10 P74859 I-th (4)

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