Whenever I run this code the while(b<63) only seems to run once then does nothing. The (a<63) loop runs fine but doesn't go again because the first loop just stops. Any idea what's going on?
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
int a,b,c,sand;
int land[64][64];
srand((unsigned)time(NULL));
a=0;
b=0;
c=0;
while(b<63)
{
while(a<63)
{
sand=rand()%100;
if(b==0)
{
if(sand<90)
{
land[a][b]=1;
a++;
}
if(sand>90)
{
while(c<8&&a<63)
{
land[a+c][b]=2;
c++;
}
a+=8;
c=0;
while(a<63)
{
land[a][b]=1;
a++;
}
}
}
if(b>=1)
{
if(land[a][b-1]==1)
land[a][b]=1;
if(land[a][b-1]==2)
{
if(sand>66)
a-=1;
if(sand<33)
a+=1;
while(c<8&&a<63)
{
land[a+c][b]=2;
c++;
}
a+=8;
}
}
}
cout<<b<<endl;
b++;
a=0;
}
//output
a=0;
b=0;
while(b<63)
{
while(a<63)
{
if(land[a][b]==1)
{
cout<<"G";
a++;
}
if(land[a][b]==2)
{
cout<<"S";
a++;
}
}
cout<<endl;
b++;
a=0;
}
cin.get();
return 0;
}
Thanks.