programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Tim Cooke
• Paul Clapham
• Devaka Cooray
• Bear Bibeault
Sheriffs:
• Junilu Lacar
• Knute Snortum
• Liutauras Vilda
Saloon Keepers:
• Ron McLeod
• Stephan van Hulst
• Tim Moores
• Tim Holloway
• Piet Souris
Bartenders:
• salvin francis
• Carey Brown
• Frits Walraven

# can't find the logic

Greenhorn
Posts: 7
hy all, i can't figure out the logic of this

The position of A and B is random. And A and B is linked by *. What is the logic of this?? do i have to make an array 10 x 10, and access the index randomly to put A??? or what??

Ranch Hand
Posts: 485
what is the actual assignment, find the A and B positions and putting *'s? If so first of all find exact location of 'A' and 'B', then put the star's.

riris wijaya
Greenhorn
Posts: 7
The assignment is to place A and B randomly, and connect it with *. So, whenever the program is run, the position of A and B is change and linked with *.

Marshal
Posts: 68936
275
• 1
Pencil and paper. That’s what you need. Write down an explanation of how you would do that. Once you have got it into very simple words (pseudo-code), it will be easy to convert to code.

Greenhorn
Posts: 13

riris wijaya wrote:hy all, i can't figure out the logic of this

The position of A and B is random. And A and B is linked by *. What is the logic of this?? do i have to make an array 10 x 10, and access the index randomly to put A??? or what??

The solution is pretty easy ;)

1. Fill A's row till B's column
2. Fill B's column till A's row

riris wijaya
Greenhorn
Posts: 7
i have found the way to place A and B randomly. Here is my scrip

but still, i can conect A and B with *. Is there any suggestion???

Bartender
Posts: 6109
6

riris wijaya wrote:
but still, i can conect A and B with *. Is there any suggestion???

Campbell Ritchie wrote:Pencil and paper. That’s what you need. Write down an explanation of how you would do that. Once you have got it into very simple words (pseudo-code), it will be easy to convert to code.

Ranch Hand
Posts: 808
My suggestion is to scrap what you have done, turn off the computer, and follow Campbell's suggestion of solving the problem with pencil and paper. If you really do this, then writing the code will be simple. Well, okay I have a second suggestion: use the power of objects!

Bartender
Posts: 5167
11

 What are your superhero powers? Go ahead and try them on this tiny ad: Two software engineers solve most of the world's problems in one K&R sized book https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton