GHETTO COWBOY 0 Newbie Poster

hi, In short I need to create a word search puzzle. I ask the user for the dimensions and words to be inserted. The hardest part is that there is a 50% chance the word should be forwards or backwards, then there is a 25% chance the word should be diagonal up to the right, 25% diagonal down the right, 25% vertical up and 25% vertical down.

I think I have the rand function down, except my teacher has said that i need to use upper bounds and lower bounds and range to find the random number, but ill work on that later.

basically i scan in the words into a vector<string> called list

for(unsigned int m=0; m<list.size(); m++){
    randomNumber = rand() % 2 + 1; // rand should give back a number 1 or 2? right?

    	if(randomNumber==1){ // so since theres a 50% chance is 1, reverse the word.
    		list[m]= string ( list[m].rbegin(), list[m].rend() );
    		randomNumber=0;
    	}

	}

and i have another vector<string> called puzzle.
this I define to be the size based on the dimensions the user provided "dim"

for(unsigned int i=0; i< dim; i++){
        puzzle.push_back("");       // Add an empty string to the puzzle object
        puzzle[i].resize(dim,'+');  // Resize the string puzzle[i] to hold dim '+' characters
    }

so for every amount of rows the user specifies, i will have the same columns.

my question is how can set the words stored in list into puzzle, in diagonal, or vertical order?

I can access the puzzle[j] where the index i selects the string in the vector and the index j selects the jth character of the string. I just have no clue how I set a one dimensional word into a diagonal or vertical word. ANY help would be greatly appreciated!! thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.