ACMICPC Live Archive 7373 Falling Blocks Falling Blocks is a

ACM-ICPC Live Archive 7373 Falling Blocks Falling Blocks is a Tetris-like arcade game, played on a board with 3 columns and 10 rows according to the following rules. A known, indefinitely repeating sequence of pentominoes (simply called pieces fall down from the top of the board, one at a time. The 8 pieces and their labels are shown below. The pieces can be rotated freely (by 0, 90, 180 or 270 degrees), but they cannot flipped. The rules are similar to that of Tetris. The newly introduced piece falls from the top of the board as far as possible until it hits the bottom of the board or an existing block in the board. Then, any rows that are completely full are removed and rows above are moved down, with no further change in the rows themselves To illustrate this, consider an empty board, on which an R piece, followed by a z piece, falls. If we drop the R piece without rotating, we end up with first board shown above. Dropping a rotated Z piece on top of it causes two rows to fill. These rows are removed, and the rows above are pushed downward. The final situation is as shown in the rightmost picture. The final position has a hanging block this block does not fall any further at this point. Unlike Tetris, the top three rows of the board must be completely empty in order to place a piece i.e., if any of the top three rows is not empty after all rows that are full, the game is over The score is solely based on the number of pieces played on the board before the game is over Given the sequence of pieces that repeats indefinitely, determine the maximum number of pieces that can be played Below are some example sequences of pieces, followed by explanation. X: Every drop of an X piece leaves two rows filled that cannot be removed by additional x pieces After placing four pieces, we have eight non-empty rows left, so the next X piece cannot be placed So the result is 4 XXXXR: The R piece could be rotated to not overlap the square left in the highest non-empty row but our rule is that the top three rows must be completely empty to place any piece. So the result is 4. VZV: Two V pieces and a Z piece can be placed to clear the board, so this game can go on forever Input The input file contains several test cases, each of them as described below The input consists of a single line that contains a single string, representing the sequence of pen tominoes. The input sequence contains between 1 and 20 characters

Solution

#include <iostream>

#include <string>

using namespace std;

int main()

{

string username;

string password;

bool success;

cout << \"\\tSecret Game\ \";

do

{

cout << \"\ Username: \";

cin >> username;

cout << \"Password: \";

cin >> password;

if (username == \"Blank\" && password == \"330\")

{

cout << \"\ Welcome to the Secret game\";

success = true;

else

{

cout << \"\ Your login failed.\";

success = false;

}

} while (!success);

return 0;

}

Here the Code For the Secret Game, I want it when the user enter the password and username its runs this code :

#include <iostream>

using namespace std;

class connectFour{

int player;

int score[2];

int board[3][10]; //3 = Rows, 10 = Columns

int move;

bool win;

public:

connectFour(){

player = 1;

score[0] = 0;

score[1] = 0;

win = false;

for (int i = 0; i < 3; i++){

for (int x = 0; x < 10; x++){

board[i][x] = 0;

}

}

}

void startTurn(){

checkWin();

if (win == true){

clearScreen();

display();

cout<< \"Player #\" << player << \" has won!\" <<endl <<endl;

}

else{

display();

gatherMove();

}

}

void display(){

clearScreen();

cout<< \" 1 2 3 4 5 6 7 8 9 10 \" <<endl;

for (int i = 0; i < 3; i++){

for (int x = 0; x < 10; x++){

cout<< \"[\" << board[i][x] << \"]\";

}

cout<< endl;

}

}

void gatherMove(){

int emptySpots = 0;

cout<< endl << \"Player #\" << player << \": Move to which space? \";

cin>> move;

if (move > 10){move = 10;}

if (move < 0){move = 0;}

for (int i = 5; i >= 0; i--){

if (board[i][move - 1] == 0){

board[i][move - 1] = player;

break;

}

else{

emptySpots += 1;

}

}

if (emptySpots == 3){

cout<< endl << \"There are no empty spots on #\" << move << \"! Try again!\";

gatherMove();

}

if (player == 1){player = 2;}

else {player = 1;}

startTurn();

}

void checkWin(){

int start = 0;

for (int i = 0; i < 3; i ++){

for (start = 0; start <= 3; start++){

if ((board[i][start] == board[i][start+1] && board[i][start+1] == board[i][start+2] && board[i][start+2] == board[i][start+3]) && (board[i][start] != 0)){

win = true;

player = board[i][start];

break;

}

}

}

for (int i = 0; i < 10; i ++){

for (start = 0; start <= 2; start++){

if ((board[start][i] == board[start+1][i] && board[start+1][i] == board[start+2][i] && board[start+2][i] == board[start+3][i]) && (board[start][i] != 0)){

win = true;

player = board[start][i];

break;

}

}

}

for (int i = 3; i < 3; i ++){

for (start = 0; start <= 3; start++){

if ((board[i][start] == board[i-1][start+1] && board[i-1][start+1] == board[i-2][start+2] && board[i-2][start+2] == board[i-3][start+3]) && (board[i][start] != 0)){

win = true;

player = board[i][start];

break;

}

}

}

for (int i = 0; i < 3; i ++){

for (start = 0; start <= 4; start++){

if ((board[i][start] == board[i+1][start+1] && board[i+1][start+1] == board[i+2][start+2] && board[i+2][start+2] == board[i+3][start+3]) && (board[i][start] != 0)){

win = true;

player = board[i][start];

break;

}

}

}

}

void clearScreen(){

system(\"clear\");

}

};

int main (int argc, char * const argv[]) {

connectFour play;

play.startTurn();

return 0;

}

 ACM-ICPC Live Archive 7373 Falling Blocks Falling Blocks is a Tetris-like arcade game, played on a board with 3 columns and 10 rows according to the following
 ACM-ICPC Live Archive 7373 Falling Blocks Falling Blocks is a Tetris-like arcade game, played on a board with 3 columns and 10 rows according to the following
 ACM-ICPC Live Archive 7373 Falling Blocks Falling Blocks is a Tetris-like arcade game, played on a board with 3 columns and 10 rows according to the following
 ACM-ICPC Live Archive 7373 Falling Blocks Falling Blocks is a Tetris-like arcade game, played on a board with 3 columns and 10 rows according to the following
 ACM-ICPC Live Archive 7373 Falling Blocks Falling Blocks is a Tetris-like arcade game, played on a board with 3 columns and 10 rows according to the following

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site