Jump to content

How fill like spiral?

- - - - -

  • Please log in to reply
2 replies to this topic

#1
qwertyuiop123

qwertyuiop123

    Newbie

  • Members
  • PipPip
  • 18 posts
Hey!

I wan't to generate a spiral filled next numbers for given parameters lines & columns.

Ex.

$lines = 5;
$columns = 6;

and result:

Attached File  24g543g5e..jpg   14.8K   16 downloads

How to do that?

Edited by qwertyuiop123, 27 May 2011 - 04:58 PM.


#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
basically, you need to know which squares is filled or not. initialize a two-dimensional array to -1 for example, and then have your limit parameters looped. if a square is filled (i.e. not -1) or limit reached then change direction on your filling.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
Roger

Roger

    If nothing goes right, go left.

  • Administrators
  • 718 posts
  • Programming Language:C, PHP
  • Learning:Python
Check out this tutorial: http://forum.codecal...like-shape.html
Check out our update Guidelines/FAQ. When posting code, remember to use code tags - Posted Image.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users