Rotating codes

I have put togather the following codes using Turbo pascal, but it wont do anything with the data I entered. It supose to display an 10 x 10 array of any characters and to be able to rotate it by 90 degree and as many times as required.

Can you please correct these codes into a working program for me, as I am just learning to program and cant get it going. Comment with changes would be very much appreciated.

with thanks

----------------------------------------
Program PatternRotation (input,output);

uses
    WinCrt;
Const
    RowMax=10;
    ColumnMax=10;

Type
    Pattern = Packed Array [1..RowMax, 1..ColumnMax] of char;

Var
  Row, Column:integer;
  ArrayTwo, ArrayOne:Pattern;
  TenArray:Pattern;
 
Procedure InputData;
begin
   writeln('Enter set of 10 characters  for arrays> ');
   readln(Row, Column);
   for row := 1 to rowmax do
   for column := 1 to columnmax do
   Readln(TenArray[row, column]);
   end;

procedure Display;
begin
    for row := 1 to rowmax do
    for column := 1 to columnmax do
    if column <> 10 then
    Write(TenArray[row, column])
    else
    Writeln(TenArray[row, column]);
    end;

Procedure rotate;
begin
    for row := 1 to rowmax do
    for column := 1 to columnmax do
    ArrayTwo[column, 11-row] :=ArrayOne[row, column];{rotate}
    writeln(row, column);
    end;

Begin
    InputData;
    Display;
    Rotate;
    end.

----------------------------------------
greenflyAsked:
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.

greenflyAuthor Commented:
Edited text of question.
0
LischkeCommented:
For more points I'd comment and correct your code, for 25 use the following hints:

- procedure Rotate works with ArryOne and ArrayTwo, they are never filled nor are they displayed
- TenArray is filled but never used in Rotate

Ciao, Mike
0
greenflyAuthor Commented:
OK talking about been tight, considering much of the work has already been done (I think). However I have increased the points to 40, Hope this will be ennought for you to help me ou here.

thanks.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

greenflyAuthor Commented:
Adjusted points to 40
0
greenflyAuthor Commented:
Adjusted points to 43
0
LischkeCommented:
Okay, I see you are giving all you have. On the other hand it's a new day and I have more time to answer your question today. Here we go:


program PatternRotation(input, output);

uses
  WinCrt;

const
  RowMax = 10;
  ColumnMax = 10;

type
  TPattern = array[1..RowMax, 1..ColumnMax] of Char;

var
  Pattern: TPattern;

procedure InputData;

// reads in our array of characters to work later on

var
  Row,
  Column: Integer;

begin
  WriteLn('Enter set of 10 characters  for arrays: ');
  for Row := 1 to RowMax do
    for Column := 1 to ColumnMax do ReadLn(ArrayOne[Row, Column]);
end;

procedure Display;

// displays the current character array in a RowMax x ColumnMax manner

var
  Row,
  Column: Integer;

begin
  WriteLn;
  WriteLn;
  for Row := 1 to RowMax do
  begin
    for Column := 1 to ColumnMax do Write(ArrayOne[Row, Column])
    WriteLn;
  end;
end;

procedure Rotate;

// modifies the entries in our character array so that it appears rotated by 90 degrees in
// clockwise direction

var
  Row,
  Column: Integer;
  Dummy: TPattern;

begin
  // make a copy of the current array so we don't overwrite values which we still need
  Dummy := Pattern;
  // go through each entry
  for Row := 1 to RowMax do
    for Column := 1 to ColumnMax do
      Pattern[Colum, RowMax - Row + 1] := Dummy[Row, Column];
end;

begin
  InputData;
  Display;
  Rotate;
  Display;
end.

As you are just start programming and I made probably the homework for you here I'd say that you at least look closer at the formatting of the code here.  This is the way most of the people as well as Inprise does it and you should do it too (indentation, capitalizing, comments, spaces etc.).

Ciao, Mike
0

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
greenflyAuthor Commented:
I am not sure what is going on but your correction to my codes do not seem to work. After entering the following set of characters
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890

and press enter it does nothing, this was the same problem with my original codes. Can you please have a quick look to see if you can spot anything wrong.

If you can't find anything wrong let me know and I will let you have your points immediately and move on to another because I realised folk like you are very busy.

Thanks for your help either way.OOPS
can you recomend a good book for learning pascal?
0
LischkeCommented:
Ooops, sorry. This was a stupid mistake on my side. I developed the code in Delphi and just used a constant array and breakpoints to check whether the code works. You need to replace ArrayOne in my code by Pattern. ArrayOne is no longer used only one array named "Pattern".

Ciao, Mike
0
greenflyAuthor Commented:
SORRY your program just do not work properly even with the modification Pattern used in place of ArrayOne.

The rotation part of the program does nothing. It supposed to give me the option to rotate the 10 x 10 array 90 degree clockwise, but it only display what I input after having to hit the <return> key 14 times.

I have tried everything my extremely limited knowledge would permit without success. However As I have promised to let you have the points for your help whether it work or not I will keep my word.

Thanks.
0
LischkeCommented:
Oh no, this is now a question of honour. Here's a complete Delphi application which works. I have just tested it!

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const
  RowMax = 5;
  ColumnMax = 5;

type
  TPattern = array[1..RowMax, 1..ColumnMax] of Char;

var
  Pattern: TPattern;
 
procedure InputData;

var
  Row,
  Column: Integer;

begin
  WriteLn('Enter set of 5 characters  for arrays: ');
  for Row := 1 to RowMax do
    for Column := 1 to ColumnMax do ReadLn(Pattern[Row, Column]);
end;

procedure Display;

// displays the current character array in a RowMax x ColumnMax manner

var
  Row,
  Column: Integer;

begin
  WriteLn;
  WriteLn;
  for Row := 1 to RowMax do
  begin
    for Column := 1 to ColumnMax do Write(Pattern[Row, Column]);
    WriteLn;
  end;
end;

procedure Rotate;

// modifies the entries in our character array so that it appears rotated by 90 degrees in
// clockwise direction

var
  Row,
  Column: Integer;
  Dummy: TPattern;

begin
  // make a copy of the current array so we don't overwrite values which we still need
  Dummy := Pattern;
  // go through each entry
  for Row := 1 to RowMax do
    for Column := 1 to ColumnMax do
      Pattern[Column, RowMax - Row + 1] := Dummy[Row, Column];
end;

begin
  InputData;
  Display;
  Rotate;
  Display;
  ReadLn;
end.


I have entered letters from a to y. NOTE: You can only enter one letter per line! So the input is:

a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y

and the output is then

abcde
fghij
klmno
pqrst
uvwxy

upkfa
vqlgb
wrmhc
xsnid
ytoje

And that's what I expected.

Ciao, Mike
0
greenflyAuthor Commented:

Have you try running this program in turbo Pascal? it just do not filp the input array below 90 degrees using the procedure rotation code.
1
12
123
1234
12345

A 90 degrees rotation should give me the shape below

11111
2222
333
44
5

but I cannot do this with the program which is what I wanted to do although the example that you used worked. I have decided to up your points from 45 to 60 for your troubles and one last try. So give a last shot and if you can't see any necessary amendment any more I will understand.

This is only a hobby for me and you have really help a lot so far there is not much to lose, except been a little disapointed.

Thanks

PS. your 60 points is on the way as soon as you reply to me, I would have like to let you have it before you reply but there is no way for to do so.




0
LischkeCommented:
Hi greenfly,

you haven't posted how the output looks in your case, but if you have entered the characters exactly as you wrote above then I do not wonder why it doesn't work. I wrote already that you can enter only ONE character per line, so you have to enter:

1
<space>
<space>
<space>
<space>
1
2
<space>
<space>
<space>
1
2
3
<space>
<space>
1
2
3
4
<space>
1
2
3
4
5


Then it works (I just tried it out).

Ciao, Mike
0
greenflyAuthor Commented:
How do I give you your point? The screen that shows the amonut of points and grading to give you no longer show when I access the URL for your answer to my question.

Or do you automatically received the points after so many tries?. Can you help?

thanks

0
LischkeCommented:
A happy new year to you, greenfly :-) I'm just back from my vacation and therefore just now able to answer...

Don't worry about the points here. You already accepted a comment as answer so you cannot accept it once more.

Ciao, Mike
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
Programming

From novice to tech pro — start learning today.