int stack[100] and int top=-1 have been defined globally and "*array_stncnt" accepts pointer to an array of integers of size accepted by variable "count"...thanks in advance for your help...
Code:
void function(int count,int *array_stncnt)
{
int i,n,index;
int *p=array_stncnt;
for(i=0;i<count;i++)
{
if(p[i]>=i)
{
push(i); /*Push called*/
push(p[i]);
}
else{}
}
while(top!=-1)
{
n=pop();
index=pop();
n=n-index;
if(n>=index)
{
push(index);
push(n);
}
else{}
count++;
}
if(count%2==0)
{
printf("\nBOB WINS");
}
else
{
printf("\nALICE WINS");
}
}
void push(int data)
{
printf("\Push fn called\n");
top++;
stack[top]=data;
printf("\nThe data aded to stack is %d",stack[top]);
}
int pop()
{
int data;
data=stack[top];
top--;
return(data);
}