When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
7 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
May I assume that the shaded area encompasses the region bounded by the left edge and diagonals from the top left corner to the centre of the matrix continuing to the lower left corner?
Assuming this is correct, something like this should work:
int main(void)
{
const int m = 100;
char matrix[m][m];
memset(matrix, '-', sizeof(matrix));
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
if (j <= i && j <= (m-1) - i) {
matrix[i][j] = '*';
}
printf("%c", matrix[i][j]);
}
printf("\n");
}
return 0;
}
$ gcc test.c
$ ./a.out
*---------
**--------
***-------
****------
*****-----
*****-----
****------
***-------
**--------
*---------
I of course ran it with m == 10
and I am sorry that it is a C example rather than a C++ example, but you get the idea I hope.
This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity