perl question

pattern matching

Page 1 of 1

2 Replies - 845 Views - Last Post: 19 August 2010 - 12:44 PM

#1 Guest_rajesh kumar gazara*


Reputation:

perl question

Posted 13 August 2010 - 01:21 AM

how can i make following pattern
  *
 * *
* * *
* * * 
 * *
  *



MOD EDIT: Added code tags to preserve indenting. Closed topic due to blatant rules violation.
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.

This post has been edited by JackOfAllTrades: 21 August 2010 - 04:46 AM


Is This A Good Question/Topic? 0

Replies To: perl question

#2 dsherohman   User is offline

  • Perl Parson
  • member icon

Reputation: 227
  • View blog
  • Posts: 654
  • Joined: 29-March 09

Re: perl question

Posted 13 August 2010 - 01:59 AM

The simplest way:
#!/usr/bin/env perl

print <<"END";
*
**
***
***
**
*
END



You'll tend to get better, more useful answers if you try to do it yourself first, then ask us to help iron out any problems rather than asking us to do all the work for you. As is often mentioned, Dream.In.Code is not a free code-writing service.
Was This Post Helpful? 0
  • +
  • -

#3 jumptrooper   User is offline

  • D.I.C Head
  • member icon

Reputation: 68
  • View blog
  • Posts: 234
  • Joined: 19-August 10

Re: perl question

Posted 19 August 2010 - 12:44 PM

View Postrajesh kumar gazara, on 13 August 2010 - 12:21 AM, said:

how can i make following pattern
*
* *
* * *
* * *
* *
*

Sounds like asking for a homework solution.
Try this: think through it step by step as if your were going to write each line yourself on graph paper. Say to yourself, "How many symbols do I need to print? How many more of each when I loopback and do the next line?" Then when you get to the widest part, ask yourself how you'll know when you get there and then think of a way to start taking away the number of symbols and spaces you need to print for each line and how to know when you're done. Seems like you're working on learning loops, so maybe read that chapter in you textbook.
It would really help if you could post what code you do have.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1