Grid Pattern
InterviewTime limit10sMemory limit512 MB
For each case, print a text grid with pipe, minus, and plus lines and asterisk-filled cells of size w by h.
- Level
Easy2 of 10
- Topics
- Implementation, Simulation, String
- Solved
- No attempts yet
Problem
Games commonly found on Unix systems in the 1970s and 1980s were designed in text mode. Many of these games use a grid as their basic layout, placing pieces or items in rows and columns. Classic examples are tic-tac-toe, chess, and minesweeper. Your task is to design a simple text-based grid layout engine that these games can use.
Given the dimensions, print a text-based grid pattern. Use | (pipe) for vertical lines, - (minus) for horizontal lines, and + (plus) where lines cross. Fill every other position with * (asterisk).
Input
The first line contains a positive integer (), the number of test cases. Each of the next lines contains four positive integers , , , and : the number of rows, the number of columns, and the width and height of a single cell. (, )
Output
For each test case, first print a line in the format Case #x:, where is the case number starting from 1. Then print the grid pattern.
The grid pattern has lines, each of length . A border line is + followed by repetitions of copies of - and one +. A cell line is | followed by repetitions of copies of * and one |. The pattern starts with a border line, and each row adds cell lines followed by one border line. See the sample output for the exact format.