Hemofobia

Untitled

Nov 23rd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 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[1000000];
  10.     int n=0;
  11.     cin>>tc;
  12.     for(int t=0; t<tc; t++){
  13.         char c=' ';
  14.         while(c!='A' && c!='D' && c!='S'){
  15.             c=getchar();
  16.         }
  17.         if(c=='A'){
  18.             int num;
  19.             cin>>num;
  20.             num=tab[n];
  21.             ++n;
  22.         }
  23.         else if(c=='D') {
  24.             if(tab[n]==NULL) // lista pusta
  25.                 cout<<"EMPTY"<<endl;
  26.             else {
  27.                 int num=tab[0];
  28.                 cout<<num<<endl;
  29.                 for(int i=0; i<n; i++){
  30.                     tab[i]=tab[i+1];
  31.                 }
  32.                 --n;
  33.             }
  34.         }
  35.         else {
  36.             cout<<n<<endl;
  37.         }
  38.     }
  39. }
Add Comment
Please, Sign In to add comment