Write a program in C++ to display the pattern like pyramid using the alphabet
- برمجة سي بلس بلس
- برمجة
- 2021-05-12
- MarwaMohammed
الأجوبة
#include <iostream>
using namespace std;
int main()
{
int i, j;
char alph = 'A';
int n, blk;
int ctr = 1;
cout << "\n\n Display the pattern like pyramid using the alphabet:\n";
cout << "---------------------------------------------------------\n";
cout << " Input the number of Letters (less than 26) in the Pyramid: ";
cin >> n;
for (i = 1; i <= n; i++) {
for (blk = 1; blk <= n - i; blk++)
cout << " ";
for (j = 0; j <= (ctr / 2); j++)
{
cout << alph++ << " ";
}
alph = alph - 2;
for (j = 0; j < (ctr / 2); j++)
{
cout << alph-- << " ";
}
ctr = ctr + 2;
alph = 'A';
cout << endl;
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال