Răspuns:
#include <iostream>
using namespace std;
int main()
{
int n,p=-1;
cin>>n;
for (int i=1;i<n;++i) {
for (int j=1;j<=n-i;++j){
cout<<" ";
}
cout<<"*";
for (int j=1;j<=p;++j){
cout<<" ";
}
if (p>0) { cout<<"*";}
p+=2;cout<<"\n";
}
for (int i=1;i<=n;++i){
cout<<"*"<<" ";
}
return 0;
}
Explicație: