C++. Loopga doir masalalar. Yulduzchalar.
Davron
Posted on May 30, 2022
Yulduzchalar yordamida *diamond shape * chop etish.
Natija:
*
***
*****
*******
*********
***********
*************
***********
*********
*******
*****
***
*
Kod:
#include<iostream>
using namespace std;
int main()
{
int i, j, rowNum, space;
cout<<"Enter the Number of Rows: ";
cin>>rowNum;
space = rowNum-1;
for(i=1; i<=rowNum; i++)
{
for(j=1; j<=space; j++)
cout<<" ";
space--;
for(j=1; j<=(2*i-1); j++)
cout<<"*";
cout<<endl;
}
space = 1;
for(i=1; i<=(rowNum-1); i++)
{
for(j=1; j<=space; j++)
cout<<" ";
space++;
for(j=1; j<=(2*(rowNum-i)-1); j++)
cout<<"*";
cout<<endl;
}
cout<<endl;
return 0;
}
Savollar va takliflaringizni Telegram ❤️ orqali qoldirishingiz mumkin.
💖 💪 🙅 🚩
Davron
Posted on May 30, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.