PHP 5/MySQL Programming- P40

PHP 5/MySQL Programming- P40:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 173 boardData width - 1 - strlen theWord The smallest legal starting value for this kind of placement is 0 because column zero always works when you re going right-to-left and the word is the same size or smaller than the puzzle which has been established . Row number doesn t matter in an Eastward placement because any row in the puzzle is legal all letters are placed on the same row. Once I know the word s largest and smallest legal starting places I can randomly generate that starting point knowing that the entire word can be placed there legally as long as it doesn t overlap any other. I used a for loop to pull one character at a time using the substr function. The for loop counter i is used to determine the starting character of the substring which is always one character long. Each character is placed at the same row as the starting character but at a column offset by the position in the word. Revisit the elephant example If the starting position chosen is column one the character E is placed in column one because E is at the 0th position in the word elephant and 1 0 1. When the counter i gets to the letter L it has the value 1 so it is placed in column two and so on. If the formula for choosing the starting place and the plan for placing subsequent letters in place work correctly you cannot add a letter outside the puzzle board. However another bad thing could happen if a character from a previously placed word is in a cell that the current word wants. The code checks the current cell on the game board to see its current status. If the cell contains the value . it is empty and the new character can be freely placed there. If the cell contains the value that the current word wants to place in the cell the program can likewise continue without interruption. However if the cell contains any other character the loop must exit and the program must reset the board and try again. Do this by setting the itWorked value to FALSE. Chapter 5 Better Arrays and String .

Không thể tạo bản xem trước, hãy bấm tải xuống
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.