You don't get the compiuter to do anything. You write the program. You are in complete control.
For example, can you randomly choose where one end of a ship will lie? Next, choose a random orientation for the ship. If you know how long the ship is, then you can check to see if the chosen placement for said ship will lie within the bounds of your array, AND if it crosses some other ship. If neither of those things is a problem, then place the ship there, and go on to the next ship.
So where is the problem? Start writing. If a probem seems too complex for you, then break it down into smaller pieces that you can solve. Then put it all together. But you need to do the work.
