0
How to print an alphabetical pyramid?
like this- A ABA ABCBAABCDCBAPLS HELP! I TRIED MANY TIMES BUT STILL I AM STUCK.
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 :)
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.