0

How to print this using for and nested for in c++

A A AB BA ABC CBA ABCD DCBA ABCDEDCBA

25th Oct 2018, 12:34 PM
MIMANSHA SWARUP
MIMANSHA SWARUP - avatar
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'); }
25th Oct 2018, 12:44 PM
Vlad Serbu
Vlad Serbu - avatar