1、
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
int i,j,n,t;
cin>>n;
t = n / 2 + 1;
for(i = 1;i <= t;i++)
{
for(j = 1;j <= i - 1;j++)
{
cout<<" ";
}
for(j = 1;j <= n;j++)
{
cout<<"*";
}
cout<<endl;
}
for(i = t - 1;i >= 1;i--)
{
for(j = 1;j <= i - 1;j++)
{
cout<<" ";
}
for(j = 1;j <= n;j++)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
2、
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,j,k;
int h,a;
cin>>h>>a;
for(i=1;i<=h;i++)
{
for(k=h-i;k>0;k--)
{
cout<<" ";
}
for(j=1;j<=a+(i-1)*2;j++)
{
cout<<"*";
}
cout << endl;
}
return 0;
}
3、
#include<iostream>
using namespace std;
int main()
{
int i=1,j,m=1,n,t,p;
char x;
cin>>n>>x;
while(n>=m)
{
i=i+1;
m=m+2*(2*i-1);
}
m=m-2*(2*i-1);
p=n-m;
j=i-1;
for(i=j;i>=1;i--)
{
n=j-i;
for(t=1;t<=j+i-1;t++)
{
if(n>0)
{
cout<<" ";
n=n-1;
}
else
cout<<x;
}
cout<<endl;
}
for(i=2;i<=j;i++)
{
n=j-i;
for(t=1;t<=j+i-1+n;t++)
{
if(n>0)
{
cout<<" ";
n=n-1;
}
else
cout<<x;
}
cout<<endl;
}
cout<<p;
return 0;
}