0
How to print this using for and nested for in c++
A A AB BA ABC CBA ABCD DCBA ABCDEDCBA
1 Réponse
0
char str[] = "ABCDEDCBA";
int i, j;
for (i = 0; i < 5; ++i) {
for (j = 0; j < 8; ++j) {
if (j <= i || j >= (7 - i))
putchar(str[j]);
else
putchar(' ');
}
putchar('\n');
}