for Robot Artificial Inteligence

8. QUEUE

|

#include <bits/stdc++.h>
#include <iostream>
using namespace std;

int Queue[1000], backID, frontID;

void push(int x)
{
    Queue[++backID] = x;
}

int Front()
{
   return Queue[frontID];
}

void pop()
{
    Queue[frontID] = 0;
    ++frontID;
}

int main()
{
    backID = -1;
    frontID = 0;

    push(5);
    push(6);
    push(7);

    cout<<Front();
    pop();
    cout<<Front();
    return 0;
}

Comments