/*
 * Etienne Bagnoud (c) 2009 <tchetch@tchetch.net>
 *
 *             DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
 *                     Version 2, December 2004
 *
 * Copyright (C) 2004 Sam Hocevar
 * 14 rue de Plaisance, 75014 Paris, France
 * Everyone is permitted to copy and distribute verbatim or modified
 * copies of this license document, and changing it is allowed as long
 * as the name is changed.
 *
 *           DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
 *  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 *
 * 0. You just DO WHAT THE FUCK YOU WANT TO. 
 */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define HEIGHT	10
#define WIDTH	26

int main(int argc, char ** argv) {

	int min = 33, max = 126;
	char matrix[HEIGHT][WIDTH];
	int i = 0, j = 0;
	unsigned int id = 0;
	int colspan=2;
	char yep = !0;

	if(argc == 2) {
		id = strtod(argv[1], NULL);
	} else {
		id = 1;
	}

	for(i=0; i < 9; i++) {
		for(j=0; j<10;j++) {
			matrix[i][j]=0;
		}
	}

	srandom(id);
	for(i=0; i<HEIGHT; i++){
		for(j=0; j<WIDTH; j++){
			/* From C Faq 13.16 */
			matrix[i][j] = (char)min + random() / (RAND_MAX / (max - min + 1) + 1);
		}
	}

	printf("<table>");

	printf("<tr>");
	for(j=0;j<WIDTH;j++) {
		if(colspan==2)
			printf("<th></th><th>%c</th>", j+65);
		else
			printf("<th>%c</th>", j+65);
		colspan=0;
	}
	printf("</tr>\n");
	
	for(i=0;i<HEIGHT;i++){
		yep = !yep;
		printf("<tr><th>%2d</th>",i);
		for(j=0;j<WIDTH;j++){
			yep = !yep;
			if(yep)
				printf("<td class=\"yep\">&#%d;</td>", matrix[i][j]);
			else
				printf("<td>&#%d;</td>", matrix[i][j]);
		}
		printf("</tr>\n");
	}
	printf("</table>");
	printf("<div class=\"cardID\"><h1>ID : %d</h1><p>%%%%MSG%%%%</p><p id=\"copyright\">%%%%COPY%%%%</p></div>\n", id);
	return 0;
}
