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,

Thanks
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.

Commented:
What have you tried, and what was unsuccessful with your coding?
0
Author 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.

thanks

0
Commented:
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]
else
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)
0

Experts Exchange Solution brought to you by

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

Commented:
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');
repeat
Write(Output,'Enter x-coord :');
Write(Output,''Enter y-coord :');
if (xcoord>=0) and (ycoord>=0) then
begin
Write(Output,'Enter the character');
Cells[xcoord,ycoord]:=ch;
end;
until (xcoord<0) or (ycoord<0);

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

More?
0
Author 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.
0
Commented:
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.
0
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
Pascal

From novice to tech pro — start learning today.