Guest User

Untitled

a guest
Apr 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.38 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. if ((scalar @ARGV) != 3)
  4. {
  5.     print "program x y density\n";
  6.     exit;
  7. }
  8.  
  9. my $x = $ARGV[0];
  10. my $y = $ARGV[1];
  11. my $density = $ARGV[2];
  12. my $i = 0;
  13. my $j = 0;
  14.  
  15. print $y . "\n";
  16.  
  17. while ($i < $y)
  18. {
  19.     $j = 0;
  20.     while ($j < $x)
  21.     {
  22.         if (int(rand($y)*2) < $density)
  23.         {
  24.             print "o";
  25.         }
  26.     else
  27.         {
  28.             print ".";
  29.         }
  30.         $j++;
  31.     }
  32.     print "\n";
  33.     $i++;
  34. }
Add Comment
Please, Sign In to add comment