Write a program in C++ to display the pattern like a diamond
- برمجة سي بلس بلس
- برمجة
- 2021-05-12
- MarwaMohammed
الأجوبة
#include <iostream>
using namespace std;
int main()
{
int i,j,r;
cout << "\n\n Display the pattern like a diamond:\n";
cout << "----------------------------------------\n";
cout << " Input number of rows (half of the diamond): ";
cin >> r;
for(i=0;i<=r;i++)
{
for(j=1;j<=r-i;j++)
cout<<" ";
for(j=1;j<=2*i-1;j++)
cout<<"*";
cout<<endl;
}
for(i=r-1;i>=1;i--)
{
for(j=1;j<=r-i;j++)
cout<<" ";
for(j=1;j<=2*i-1;j++)
cout<<"*";
cout<<endl;;
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال