The Rantings of a Teenager in the Prime Crap-itude of High School

Friday, November 04, 2005

C++

So who, besides Eric and Asif, can figure out what this fun Little block of C++ can do?

#include
#include iostream
#include string.h
#include ctime

using namespace std;
// How to get a file to open! --> system("dropa.bmp");

int score1=0, score2=0, turn=1,z,y,havecard1=0,havecard2=0;//score for player1, score for player2, whos turn is it, used in functions, see "z"

int sq11=0, sq12=0, sq13=0, sq14=0, sq21=0, sq22=0, sq23=0, sq24=0, sq31=0, sq32=0, sq33=0, sq34=0;
//defines wheter or not the square has been matched with another square, if the square(s) have been matched, then they equal 1

int board[3][4];

int boardgen()
{
srand((unsigned)time(0));
board[0][0]=(rand()%12)+1;
board[0][1]=(rand()%12)+1;
board[0][2]=(rand()%12)+1;
board[0][3]=(rand()%12)+1;
board[1][0]=(rand()%12)+1;
board[1][1]=(rand()%12)+1;
board[1][2]=(rand()%12)+1;
board[1][3]=(rand()%12)+1;
board[2][0]=(rand()%12)+1;
board[2][1]=(rand()%12)+1;
board[2][2]=(rand()%12)+1;
board[2][3]=(rand()%12)+1;
while ((board[0][1]== board[0][0]))
{board[0][1]=(rand()%12)+1;}
while ((board[0][2]== board[0][0])||(board[0][2]== board[0][1]))
{board[0][2]=(rand()%12)+1;}
while ((board[0][3]== board[0][0])||(board[0][3]== board[0][1])||(board[0][3]== board[0][2]))
{board[0][3]=(rand()%12)+1;}
while ((board[1][0]== board[0][0])||(board[1][0]== board[0][1])||(board[1][0]== board[0][2])||(board[1][0]== board[0][3]))
{board[1][0]=(rand()%12)+1;}
while ((board[1][1]== board[0][0])||(board[1][1]== board[0][1])||(board[1][1]== board[0][2])||(board[1][1]== board[0][3])||(board[1][1]== board[1][0]))
{board[1][1]=(rand()%12)+1;}
while ((board[1][2]== board[0][0])||(board[1][2]== board[0][1])||(board[1][2]== board[0][2])||(board[1][2]== board[0][3])||(board[1][2]== board[1][0])||(board[1][2]== board[1][1]))
{board[1][2]=(rand()%12)+1;}
while ((board[1][3]== board[0][0])||(board[1][3]== board[0][1])||(board[1][3]== board[0][2])||(board[1][3]== board[0][3])||(board[1][3]== board[1][0])||(board[1][3]== board[1][1])||(board[1][3]== board[1][2]))
{board[1][3]=(rand()%12)+1;}
while ((board[2][0]== board[0][0])||(board[2][0]== board[0][1])||(board[2][0]== board[0][2])||(board[2][0]== board[0][3])||(board[2][0]== board[1][0])||(board[2][0]== board[1][1])||(board[2][0]== board[1][2])||(board[2][0]=
=board[1][3]))
{board[2][0]=(rand()%12)+1;}
while ((board[2][1]== board[0][0])||(board[2][1]== board[0][1])||(board[2][1]== board[0][2])||(board[2][1]== board[0][3])||(board[2][1]== board[1][0])||(board[2][1]== board[1][1])||(board[2][1]== board[1][2])||(board[2][1]==board[1][3])||(board[2][1]==board[2][0]))
{board[2][1]=(rand()%12)+1;}
while ((board[2][2]== board[0][0])||(board[2][2]== board[0][1])||(board[2][2]== board[0][2])||(board[2][2]== board[0][3])||(board[2][2]== board[1][0])||(board[2][2]== board[1][1])||(board[2][2]== board[1][2])||(board[2][2]==board[1][3])||(board[2][2]==board[2][0])||(board[2][2]==board[2][1]))
{board[2][2]=(rand()%12)+1;}
while ((board[2][3]== board[0][0])||(board[2][3]== board[0][1])||(board[2][3]== board[0][2])||(board[2][3]== board[0][3])||(board[2][3]== board[1][0])||(board[2][3]== board[1][1])||(board[2][3]== board[1][2])||(board[2][3]==board[1][3])||(board[2][3]==board[2][0])||(board[2][3]==board[2][1])||(board[2][3]==board[2][1]))

int main()
{
boardgen();

system("pause");
return 0;
}


Toodles!

FYI It won't allow carrots, so this won't compile without them.

Motor.On

2 Comments:

Blogger Eric said...

This won't compile anyway, because the final while statement has no execution block (i.e. Nothing runs during the while, nothing the curly brackets). I'm curious: why'd you use a two dimensional array?

2:17 PM

 
Blogger Motor.On said...

It was easier for me to know where it was. I dunno. I jsut did

12:41 PM

 

Post a Comment

<< Home