Hemofobia

Untitled

Nov 23rd, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include<cstdio>
  2. #include<list>
  3. #include<iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8.     int tc;
  9.     int tab[100000];
  10.     for(int i=0; i<100000; i++){
  11.         tab[i]=-1;
  12.     }
  13.     int n=0;
  14.     cin>>tc;
  15.     for(int t=0; t<tc; t++){
  16.         char c=' ';
  17.         while(c!='A' && c!='D' && c!='S'){
  18.             c=getchar();
  19.         }
  20.         if(c=='A'){
  21.             int num;
  22.             cin>>num;
  23.             num=tab[n];
  24.             ++n;
  25.         }
  26.         else if(c=='D') {
  27.             if(tab[n]==-1) // lista pusta
  28.                 cout<<"EMPTY"<<endl;
  29.             else {
  30.                 int num=tab[0];
  31.                 cout<<num<<endl;
  32.                 for(int i=0; i<n; i++){
  33.                     tab[i]=tab[i+1];
  34.                 }
  35.                 --n;
  36.             }
  37.         }
  38.         else {
  39.             cout<<n<<endl;
  40.         }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment