Question: C++ Visual Studio Please run your program and make sure you get the same output as showing down below. Program: Write a program like the
C++
Visual Studio
Please run your program and make sure you get the same output as showing down below.
Program:
Write a program like the 4096-tile game that prints out new board given an existing board and a direction to shift to. The rules are as follows: One can only swipe left, right, up, and down The game is set on a 4 x 4 tile board Each tile will have the one of the following values: *, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, and 4096 When one swipes in a direction all the tiles will shift in that direction if the tile in front of it is of the same value or it is a space denoted by an *. If the swiped tiles are the same value, they will combine into one tile of the value of one of the tiles times 2. Each row and column are independent of each other A tile can only be combined once in a turn. For example, 2 2 2 2 yields * * 4 4 instead of * * * 8 Input from a datafile. The first line of the data files contains a single integer n that indicates the number of data sets that follow. Each data set will contain a 4x4 4096 board followed by a direction to shift the board. Each tile of the board is separated by a space. For each board, output to the screen the board after it has been shifted by the requested direction. Let the user input the file name from the keyboard. Use any appropriate data structure. Refer to the sample output below.
Program File: 2 * * * * * * * * * * * * 2 2 * * left 2 2 2 * 4 8 4 * 16 32 8 4 * * * * right
Sample Output: Enter file name: 4096.txt Board 1: * * * * * * * * * * * * 4 * * * Board 2: * * 2 4 * 4 8 4 16 32 8 4 * * * *
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
