Skip to content

Instantly share code, notes, and snippets.

@dlsym
Created May 28, 2012 12:36
Show Gist options
  • Save dlsym/2818948 to your computer and use it in GitHub Desktop.
Save dlsym/2818948 to your computer and use it in GitHub Desktop.
Feld...
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define WIDTH 10
int main()
{
int field[WIDTH][WIDTH];
srand(time(NULL));
// initialize field
for( int i = 0; i < WIDTH; i++ ) {
for( int j = 0; j < WIDTH; j++ ) {
field[i][j] = rand()%2;
}
}
// print field
for( int i = 0; i < WIDTH; i++ ) {
for( int j = 0; j < WIDTH; j++ ) {
printf( " %d ", field[i][j] );
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment