/*
Input : HEMANT
*/
class Triangle
{
String arg;
Triangle(String s) //Constructor
{
arg=s;
}
public void printTriangle()
{
for(int i=0;i
for(int j=i;j
System.out.print(" ");
}
System.out.print(arg.charAt(i)+" ");
for(int j=1;j<(i*2);j++)
{
System.out.print(" ");
}
if(i!=0)
System.out.print(arg.charAt(i)+" ");
System.out.println();
}
for(int i=arg.length()-2;i>=0;i--)
{
for(int j=i;j
System.out.print(" ");
}
System.out.print(arg.charAt(i)+" ");
for(int j=1;j<(i*2);j++)
{
System.out.print(" ");
}
if(i!=0)
System.out.print(arg.charAt(i)+" ");
System.out.println();
}
}
}
class 10thB
{
public static void main(String args[])
{
String s=args[0];
Triangle t=new Triangle(s);
t.printTriangle();
}
}
0 comments:
Post a Comment