Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- using namespace std;
- class array{
- private:
- int amount; //iloΕΔ elementΓ³w tablicy
- int *tab;
- int sizetab; //rozmiar tablicy
- public:
- array(int x){
- sizetab=x;
- amount=-1;
- tab=new int[sizetab];
- }
- void add_element(int sizetab){
- if(amount<=1000000){
- if(sizetab<=1000000 && sizetab>=0){
- tab[amount]=sizetab;
- ++amount;
- return;
- }
- }
- }
- void add_tab(){
- int *tab2=new int[sizetab];
- for(int i=0; i<sizetab; i++){
- tab2[i]=tab[i];
- }
- }
- int get_amount(){
- return amount+1;
- }
- void delete_first(){
- if(amount>0)
- for(int i=0; i<=amount; i++){
- tab[i]=tab[i+1];
- }
- --amount;
- return;
- }
- int first(){
- return tab[0];
- }
- };
- int main(){
- int num;
- int tc;
- array tab(1);
- scanf("%d", &tc);
- for(int t=0; t<tc; t++){
- char c=' ';
- while(c!='A' && c!='D' && c!='S')
- c=getchar();
- if(c=='A'){
- scanf("%d", &num);
- tab.add_element(num);
- }
- else if(c=='D'){
- if(tab.get_amount()==0){
- printf("EMPTY\n");
- continue;
- }
- else
- cout<<tab.first()<<endl;
- tab.delete_first();
- }
- else{
- cout<<tab.get_amount()<<endl;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment