设为首页 加入收藏

TOP

Google校招在线测试题---2048游戏(二)
2014-11-23 19:02:21 来源: 作者: 【 】 浏览:85
Tags:Google 在线 测试题 ---2048 游戏
ove the feel when two tiles are merged. After a few round, they start to be bored about the size of the board and decide to extend the size of board to N x N, which they called the game "Super 2048".


The big board then makes them dazzled (no zuo no die -_-| ). They ask you to write a program to help them figure out what the board will be looked like after all tiles move to one specific direction on a given board.


The first line of the input gives the number of test cases, T. T test cases follow. The first line of each test case gives the side length of the board, N, and the direction the tiles will move to, DIR. N and DIR are separated by a single space. DIR will be one of four strings: "left", "right", "up", or "down".


The next N lines each contain N space-separated integers describing the original state of the board. Each line represents a row of the board (from top to bottom); each integer represents the value of a tile (or 0 if there is no number at that position).


For each test case, output one line containing "Case #x:", where x is the test case number (starting from 1). Then output N more lines, each containing N space-separated integers which describe the board after the move in the same format as the input.


Each number in the grid is either 0 or a power of two between 2 and 1024, inclusive.


1 ≤ T ≤ 20
1 ≤ N ≤ 4


1 ≤ T ≤ 100
1 ≤ N ≤ 20


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇面试心经---如何更好的调整面试状.. 下一篇Java线程池框架源码分析

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: