-
Here is what I have thus far...what is wrong w/ it?!!! I am so confused, Please help me. Thank you!
Code:
/*
* Program: BINGO
* Author: Mark Smith
* Date: 4/9/09
* Input:
* Output:
* Description:bingo game project 3
* */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
void about();
void copyrandword(char *word);
void assignwords(char card[5][5][30]);
char BingoWords[75][30]={"acid","atom","average","axis","base",
"bonding","circuit","chemical","dispersion","derivative",
"electricity","electron","energy","engineer","equation","force",
"friction","flammable","fluorine","fusion","if-then-else",
"getchar","gets","grams","gas","ideal gas law","integer",
"inertia","integral","joule","kilogram","Kalvin","liter","liquid",
"longitude","meter","math","mole","milliliter","molecule","Newton",
"neutron","nucleus","optics","orbitals","p-orbital","pounds",
"proton","pressure","quark","resistor","s-orbital","science",
"scientist","stoichiometry","strain","stress","solution","time",
"tension","Uranium","variables","variance","velocity","virtual",
"waves","wavelength","weight","x-axis","X-ray","Xenon","y-axis",
"Yttrium","z-axis","Zinc"};
void displaycard();
void wordtest();
void gamewinner();
int main()
{
int i;
//create card
char cardObject[5][5][30];
srand(time(NULL));
about();
assignwords( cardObject );
printf("\n");
printf("| B |");
printf(" I |");
printf(" N |");
printf(" G |");
printf(" O |");
printf("\n");
//print all words
for(i=0;i<75;i++)
{
printf("| %s |", BingoWords[i]);
if (i%5==0)
{
printf("\n");
}
}
return(0);
}
void about()
{
printf(" WELCOME TO WORD-BINGO!\n");
printf("This is a two player game. Each player is given\n");
printf("one BINGO card. Instead of numbers or symbols, this\n");
printf("BINGO game involves words related to math, science, and\n");
printf("engineering.");
}
void copyrandword(char *word)
{
int i=rand() % 75;
strcpy(word, BingoWords[i]);
}
void assignwords( char card[5][5][30])
{
int i, j;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
copyrandword( card[i][j] );
}
}
}
void displaycard( char card[5][5][30])
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
copyrandword( card[i][j] );
}
}
for(i=0;i<25;i++)
{
for(j=0;j<25;j++)
{
printf("| %s ", card[i][j]);
if((i%5)==0)
{
printf("\n");
}
if(card[i][j]=card[3][3])
{
printf("| FREE ");
}
}
}
}
-
Quote:
what is wrong w/ it?!!!
How about you tell us. What is wrong with it? What should it do? What does it, or doesn't it do? If you want help, it's generally a good idea to explain what's going on.
Quzah.
-
Sorry for the confusion.
I am having trouble printing out, on the screen, a 5x5 card (middle space=FREE) with a random assortment of 25 BingoWords[75][30]. More specifically, how alphabetically arrange them with the 5x5 card. For example, column B= words a-e,
I=f-j,
N=k-o,
G=p-t
O=u-z
Also, I am having trouble calling out a random word, checking to see if a box contains that word, and if it does, how to go about replacing the string/word with an "x" signifying that it is covered.
Any ideas/examples?
Thank you very much. Sorry for the confusion once again
-
Work on one thing at a time. Let's do the easy part, displaying words. You have to do them by rows, because of the way the standard output ends up working with your screen. So...
Code:
for each row
for each column
display this segment
put a newline
Now, the first row is the letters for the word bingo. So include a clause checking for row 0.
The next two are a full five words.
The next consists of two words, a blank box saying "BINGO" or whatever, and two more. You'll need a clause checking for that center position.
Finally, another full two rows.
Don't worry about getting all of the rest of the stuff down. Take baby steps. Just make a function that fits in that pair of loops, that will display a string.
After you can make it match the above description, try making it center its output in each "box". Stop worrying about anything else until you can draw a simple card.
Quzah.
-
Just for giggled.... Lemme see what I can think of
Code:
#include <stdarg.h>
#include <stdlib.h>
struct puzzle_t
{
char name[1];
struct puzzle_t *up, *down, *left, *right;
};
struct puzzle_t *make_row(struct puzzle_t *parent, int n, ...)
{
const char *item;
struct puzzle_t *child;
va_list list;
child = 0;
va_start(list, n);
for(;--n;)
{
item = va_arg(list, char *);
if(!child)
{
child = malloc(sizeof(*parent) + strlen(item));
} else
{
if((child->right = malloc(sizeof(*parent) + strlen(item))))
{
child->right->left = child;
child = child->right;
child->right = 0;
}
}
if(parent)
{
child->top = parent;
parent->bottom = child;
parent = parent->right;
}
if(child)
strcpy(child->name, item);
}
va_end(list);
}
Its something to start with :-)