วันอังคารที่ 2 มีนาคม พ.ศ. 2553

*****ประเดิม...???

5 ความคิดเห็น:

  1. stack


    #include
    #include

    #define MAX 10

    int stackdata[MAX];
    int top=-1;

    int push(int what)
    {
    clrscr();
    if (top-1)
    {
    r=stackdata[top];
    stackdata[top]=0;
    top--;
    return r;
    }
    return -1;
    }

    void main()
    {
    push(7);
    push(12);
    push(23);
    push(2);
    push(33);
    push(10);

    printf("Pop=%d\n",Pop());
    printf("Pop=%d\n",Pop());
    printf("Pop=%d\n",Pop());
    printf("Pop=%d\n",Pop());
    printf("Pop=%d\n",Pop());
    printf("Pop=%d\n",Pop());

    getch();

    }

    ตอบลบ
  2. queue


    #include

    #define MAX 10
    int queuedata[MAX];
    int front=0;
    int rear=0;

    int add(int data)
    {
    if (rearrear)
    {
    front=0;
    rear=0;
    return -1;
    }
    else
    front++;
    }
    else
    return -1;
    return temp;
    }


    void main()
    {
    int i;
    add(5);
    add(6);
    add(7);
    add(8);
    add(9);
    add(10);
    add(11);
    add(12);
    add(13);
    printf("add result = %d\n",add(14));
    printf("add result = %d\n",add(14));

    show();

    printf("\n");
    for (i=1;i<=10;i++)
    {
    printf("%d. get data = %d\n",i,get());
    }
    getch();

    }

    ตอบลบ
  3. ----Stack สอบระหว่างภาค----

    #include
    #include
    #include

    #define MAX 4

    int stackdata[MAX];
    int top=-1;

    int push(char what)
    {

    if (top-1)
    {
    r=stackdata[top];
    stackdata[top]=0;
    top--;
    return r;
    }
    return -1;
    }

    void main()
    {


    char texttoinput;
    int i;


    clrscr() ;

    push('S');
    push('A');
    push('T');
    push('A');

    for (i=1;i<=4;i++)
    {
    printf("DELETE TOP STACK %d IS %c\n",i,Pop());
    }


    getch();

    }

    ตอบลบ
  4. #include

    #define MAX 11
    int queuedata[MAX];
    int front=0;
    int rear=0;

    int add(int data)
    {
    if (rearrear)
    {
    front=0;
    rear=0;
    return -1;
    }
    else
    front++;
    }
    else
    return -1;
    return temp;
    }


    void main()
    {
    int i;

    clrscr();

    add('A');
    add('C');
    add('C');
    add('D');
    add('E');
    add('F');
    add('G');
    add('H');
    add('I');
    add('J');
    // printf("add result = %d\n",add(14));
    // printf("add result = %d\n",add(14));

    show();

    printf("\n");
    for (i=1;i<=10;i++)
    {
    printf("%d. get data = %c\n",i,get());
    }
    getch();

    }

    ตอบลบ