UTS Programming Competition 2019 Problem 1

From ProgSoc Wiki

Jump to: navigation, search

This is a part of the UTS Programming Competition 2019 Problem Set.

Problem 1: ASCII Cross

Run time limit: 1 second

Problem Description

Welcome to the 2019 UTS Programming Competition! We hope you enjoy your stay.

What better way to make your mark, so to speak, on this competition than by drawing an ASCII cross!

It's really simple -- just follow the instructions below and you can't go wrong!

Data Specification

Input

A single integer, N, where 1 <= N <= 20, denoting the length of each spur of the cross.

Output

To draw a cross of size N, you will need to output 2N + 1 lines. Each line shall contain 2N + 1 characters. In other words, you will create a square grid with 2N + 1 rows and 2N + 1 columns.

To draw the left-to-right diagonal, output an asterisk (*) on row X and column X of the grid, where 1 <= X <= 2N + 1.

To draw the right-to-left diagonal, output an asterisk (*) on row X and column (2N + 2 - X) of the grid, where 1 <= X <= 2N + 1.

All of the other characters on the grid shall be underscore characters (_).

Sample Input

5

Sample Output

*_________*
_*_______*_
__*_____*__
___*___*___
____*_*____
_____*_____
____*_*____
___*___*___
__*_____*__
_*_______*_
*_________*

Solutions

Put your solutions here!

Personal tools