11607. ASCII Art
You are given a matrix A of size h ?
w consisting of integers from 0 to 26. The element located in the i-th row from the top and the j-th column from the left is denoted by Ai,j.
Let s1, s2,
…, sh be strings of length w, defined as follows:
Print the strings s1, s2,
…, sh, one per line.
Input. The
first line contains two integers h and w – the height and width
of the matrix A.
The next h lines contain w integers
each – the elements of the matrix A.
Output. Print h lines. In the i-th line print the string si.
|
Sample input 1 |
Sample output
1 |
|
2 3 0 1 2 0 0 3 |
.AB ..C |
|
|
|
|
Sample input 2 |
Sample output
2 |
|
3 3 24 0 0 0 25 0 0 0 26 |
X.. .Y. ..Z |
two-dimensional array
You are given a matrix of
size h ? w. Each number should be replaced with a
character:
·
if the number is 0, print a dot.
·
if the number is between 1 and 26, print the corresponding uppercase
letter of the English alphabet.
Let Ai,j = x. It is known that the
value x = 1 corresponds to the letter ‘A’, and the value x = 26 corresponds to the
letter ‘Z’. Therefore, if Ai,j = x, the character to print in the
corresponding position is x + ‘A’ – 1.
Algorithm implementation
Read
the dimensions of the matrix.
scanf("%d %d", &h, &w);
Iterate
through the matrix, and for each value x, print the corresponding
character.
for (i = 0; i < h; i++)
{
for (j = 0; j < w;
j++)
{
scanf("%d", &x);
if (x == 0) printf(".");
else printf("%c", x + 'A' - 1);
}
printf("\n");
}