//user inputs 5
*
***
*****
***
*
The other two are tied for the lead at 176 characters, including spaces but not including invisible(\n), so they decided to use the forum of their choice to see who can get the shorter code. Of course, I am still in this thing (sort-of) with 194 characters, so I complained and was able to use the forum of my choice. I have never posted on this forum but since you guys always explain in detail, I learn what I need to know.
My code is below; I have broken it so others cannot copy-paste-turnin, but the break is pretty obvious to long-time Java programmers.
class
d{
public
static
void
main(String[]a)
int
n=new
Byte(a[0]),
i=1,f=1;
for(String
l="*";i>0;i+=f,f=n<=i*2?-1:f){
System.out.printf("%"+n+i+"s%n",l);
if(f<0)l=l.replaceFirst("\\*\\*","");
else
l+="**";
}}}

New Topic/Question
Reply



MultiQuote









|