Hirdetés

Új hozzászólás Aktív témák

  • ktg3

    őstag

    vki pls help me :U
    mindjárt leverem a gépet az asztalról mert nem megy és 1szerűen nem tudom h hol a hiba :O

    //main

    #include ''fifo.h''
    #include <stdio.h>



    void main ()
    {
    int array[]={0,1,2,3,4,5,6,7,8,9};

    fifo m;
    for(int i=0;i=9;i++)
    m.push(array);

    printf (''%d\n'', m.pop());


    }


    //fifo.h

    #ifndef FIFO_H
    #define FIFO_H


    class fifo
    {
    int *t,elementnum;


    public:

    fifo () {t=0,elementnum=0;}
    void push (int n);
    int pop ();
    ~fifo (){delete []t;}

    };


    #endif

    //fifo fgvk

    #include <stdio.h>
    #include ''fifo.h''


    void fifo::push (int n)
    {
    int *tmp,i;
    tmp=new int [elementnum+1];
    for (i=0;i<elementnum;i++)
    tmp
    =t;
    tmp[elementnum-1]=n;
    delete []t;
    elementnum++;
    t=tmp;

    }


    fifo::pop ()
    {
    int *tmp,i,x;
    tmp=new int [elementnum-1];
    for (i=0;i<elementnum-1;i++)
    tmp
    =t;
    x=t[elementnum];
    delete []t;
    elementnum--;
    t=tmp;
    return x;
    }

Új hozzászólás Aktív témák