Can Someone please help with my code.

closed account (2NywAqkS)
Recently I have been learning to use arrays and on visual c++ express 2010 I made a program that was vaguely meant to represent a city with streets. I have used a few of my own headers but they work fine on other program i have tried so I know there not the problem

// This early prototype Maps out a simple 20 * 20 city with streets
#include <iostream>
#include "random.h"
#include "pause.h"
#define SIZE 20

using namespace std;

int main()
{
// Creates the City-Space
bool city [SIZE][SIZE] = {0};

// Creates Streets
int Streetsx;
for (Streetsx = 0; Streetsx == random(SIZE / 5) + SIZE / 5; Streetsx++)
{
int n = random(SIZE);
int x;
for (x = 0; x == SIZE; x++) city [n][x] = 1;
}
int Streetsy;
for (Streetsy = 0; Streetsy == random(SIZE / 5) + SIZE / 5; Streetsy++)
{
int n = random(SIZE);
int x;
for (x = 0; x == SIZE; x++) city [x][n] = 1;
}


// Draws The City
int dx, dy;
for (dx = 0;dx < SIZE; dx++)
{
for (dy = 0;dy < SIZE; dy++)
{
cout << city[dx][dy] << " ";
if (dy == SIZE - 1) cout << "\n";
}
}
pause ();
}

The building are represented as 0's and the streets as 1's, but for some reason there weren't any rows and columns of 1's as I had hoped.

Any help is much appreciated. thanks Rowan

p.s a quick explanation of how to group header files would be nice
for (Streetsx = 0; Streetsx == random(SIZE / 5) + SIZE / 5; Streetsx++)

You set Streetsx to 0, then execute the for loop as long as Streetsx is equal to a random number between 5 and 8 repeat the loop. This for loop will never execute.
closed account (2NywAqkS)
thanks very much
Topic archived. No new replies allowed.