#include<string.h>
#include<iostream.h>
#include<math.h>
int i,j,n;
char u[20];
void main()
{
cout<<"Imput the the word from keyboard and press Enter: ";cin.get(u,20);
n=strlen(u);
cout<<endl;
if(strlen(u)%2!=0)
{ for(i=0;i<=n/2;i++)
{cout.width(i+3);cout.fill(' ');
for(j=i;j<n-i;j++)
cout<<u[j];
cout<<endl;
}
for(i=0;i<=n/2;i++)
{
cout.width(n/2-i+3);cout.fill(' ');
for(j=(n/2)-i;j<(n/2)+i+1;j++)
cout<<u[j];
cout<<endl;
}
}
else
{ for(i=0;i<=n/2;i++)
{cout.width(i+3);cout.fill(' ');
for(j=i;j<n-i;j++)
cout<<u[j];
cout<<endl;
}
for(i=0;i<n/2;i++)
{
cout.width((n+1)/2-i+2);cout.fill(' ');
for(j=(n/2)-i-1;j<((n+1)/2)+1+i;j++)
cout<<u[j];
cout<<endl;
}
}
}
Display a word read from keyboard in elipsoid form
Saturday, 24 March 2012 | 0 Comments