xxxxxxxxxx
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n ;
for(int i=1 ; i <= n ; i++){
for(int j=i ; j < n; j++){
printf(" ");
}
for(int j=1 ; j <= i*2-1 ; j++){
printf("*");
}
printf("\n");
}
return 0;
}
/**
*
***
*****
*******
*/
xxxxxxxxxx
#include <iostream>
using namespace std;
int main()
{
int rows;
cout << "Enter number of rows: ";
cin >> rows;
int i = 1;
while(i <= rows)
{
int j = 1
while(j <= i)
{
cout << "* ";
j++
}
cout << "\n";
i++;
}
return 0;
}
xxxxxxxxxx
int num{}, i{1};
cin >> num;
while (i <= num) {
for (int space = 1; space <= (num - i); space++) { // space
cout << " ";
}
for (int value = 1; value <= (2 * i - 1); value++) { // value
cout << value;
}
cout << endl; //next row
i++;
}