0

How to print an alphabetical pyramid?

like this- A ABA ABCBAABCDCBAPLS HELP! I TRIED MANY TIMES BUT STILL I AM STUCK.

4th Aug 2016, 1:25 PM
Siddhant Saxena
Siddhant Saxena - avatar
2 ответов
+ 1
#include <iostream> #include <string> using namespace std; int main() { char *alpha = "abcdefghijklmnopqrstuvwxyz"; for (int a = 0; a <= 25; a++) { cout << string(26 - a, ' '); for (int b = 0; b <= a; b++) cout << *(alpha + b); cout << "\n"; } } That's the best I can do with my knowledge. There is probably a simpler way, but anyone else is welcome to show it :)
4th Aug 2016, 2:21 PM
Cohen Creber
Cohen Creber - avatar
0
It'd be great if you post the code of your latest try. That way we'll tell you how you can modify your code to achieve that.
4th Aug 2016, 2:12 PM
Nick D.
Nick D. - avatar