The col value automatically got changed to 1048576000 after for loop why is this I got no clue for that. And because of this the index value in final step goes out of the bound. The code is
#include<bits/stdc++.h>
using namespace std;
void fill(float k,int row,int col)
{
    float glass[row*(row+1)/2]={0.0};
    int index=0;
    glass[index]=k;
    for(int i=1;i<=row;i++)
    {
        for(int j=1;j<=i;j++)
        {
            k=glass[index];
            glass[index]=(k>=1.0)?1.0:k;
            k=(k>1.0)?(k-1.0):0.0;
            glass[index+i]+=k/2.0;
            glass[index+i+1]+=k/2.0;
            index++;
        }
    }
    cout<<col<<endl;
    index=row*(row-1)/2 +col -1;
    cout<<glass[index]<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        float k;
        int i,j;
        cin>>k>>i>>j;
        fill(k,i,j);
    }
    return 0;
}
Please help me out.
