Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > RE: Writing sid...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 11030 of 11065
Post > Topic >>

RE: Writing side of square

by t.baetzler@[EMAIL PROTECTED] (T Baetzler) May 5, 2008 at 04:16 PM

Rodrigo Tavares <digolinopage@[EMAIL PROTECTED]
> asked:
> I need create a square using a single number, but I don't=20
> know how to create the sides.

#!/usr/bin/perl -w

use strict;

for( my $n =3D 1 ; $n <=3D 10; $n++ ){

  print "\nn =3D $n\n\n";

  if( $n =3D=3D 1 ){
    print "*\n";
  } else {
    print '*'x$n . "\n";
    for( my $line =3D 2; $line < $n; $line ++ ){
      print '*' . ' 'x($n-2) . "*\n";
    }
    print '*'x$n . "\n";
  }

}

__END__

HTH,
Thomas




 1 Posts in Topic:
RE: Writing side of square
t.baetzler@[EMAIL PROTECT  2008-05-05 16:16:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 15:03:51 CDT 2008.