Rotate Pattern

How can I input any design or pattern from the keyboard into
10 x10 array of characters. Then on the user's request display the pattern rotated by 90 degrees clockwise. It must allow as many rotation as desired by the user. Four consecutive rotations must returned the display to the original pattern.?

The program language for coding this problem must be in Turbo Pascal. I have tried several coding without success.
I am just learning to program in pascal and having problem writing this exercise. An urgent response would be very much appreciated,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What have you tried, and what was unsuccessful with your coding?
greenflyAuthor Commented:
Basically I tried to write the codes using packed arrays[1..10]of char, with a procedure to input each row of arrays as a string but I had compilation problems. To be honest I am not even sure if my array coding was correct because I have not use arrays before, but just tried it based on bits and pieces from books. Through frustration I scrapped the codes I wrote, otherwise I would have send it to you.

Look if you can Produced the full program codes in pascal in your next reply I would appreciate it very much.


Try a 2 x 2 array first before you use a 10 x 10 array.

Here is an input procedure

for i := 1 to 2 do
 for j := 1 to 2 do
   Readln(TableArray[i, j]);  { type a character and press Enter }

The Same procedure can be used to output

for i := 1 to 2 do
  for j := 1 to 2 do
     if j <> 2 then
        Write(TableArray[i, j]
        Writeln(TableArray[i, j];
The rotation is up to you to do but if you can understand what is going on here it shouldn't be too had (HINT: Another array might be useful)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

I presume that 90% of the array (10x10) is empty. Only a few cells will contain any characters to make a pattern. So first clear the arrays :-
   for i:=1 to 10 do
      Cells[i]:='          ';

 Then a bit of code like :-

   Writeln(Output,'Enter -1 to finish');
     Write(Output,'Enter x-coord :');
     Write(Output,''Enter y-coord :');
     if (xcoord>=0) and (ycoord>=0) then
        Write(Output,'Enter the character');
   until (xcoord<0) or (ycoord<0);

Strictly you should check that xcoord and ycoord lie between 1 and 10 (or 0 and 9).

greenflyAuthor Commented:
Your reply will help me a lot, But I could do with a hint or something on the rotation bit. Is that too much to ask? go on, please?

Anyway you deserve your points, I also received another useful answer from someone else but I haven't a clue how to share points between two good answers.  
Assume you have two arrays of 2 x 2

for i := 1 to 2 do
  for j := 1 to 2 do
     ArrayTwo(j, 3-i] := ArrayOne[i, j]

I think this will work.  All your rotations are based on this one.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.