this should help
Code:
#include <iostream>
using namespace std;
void print(int rowsize);
int main()
{
int rowsize;
do{
cout<<"Please type in a positive odd integer: ";
cin>>rowsize;
}while((rowsize%2==0)||(rowsize<=0));
print(rowsize);
return (0);
}
void print(int rowsize)
{
int spaces=rowsize/2, currentsize=1, counter, count;
for(counter=0;counter!=(rowsize+1)/2;counter++){
for(count=spaces;count!=0;count--)
cout<<" ";
spaces--;
for(count=currentsize;count!=0;count--)
cout<<"*";
currentsize+=2;
cout<<endl;
}
currentsize=rowsize-2;
spaces+=2;
for(counter=rowsize/2;counter!=0;counter--){
for(count=0;count!=spaces;count++)
cout<<" ";
spaces++;
for(count=currentsize;count!=0;count--)
cout<<"*";
currentsize-=2;
cout<<endl;
}
}