RE: [PBML] Query - Converting an Array into another one

Expand Messages
• Okay. I got your point. And I couldnt agree more. But maybe I am being totally misinterpreted here. I had solutions to the puzzle. (See below) I just wanted to
Message 1 of 7 , Mar 29, 2006
Okay. I got your point. And I couldnt agree more.

But maybe I am being totally misinterpreted here.

I had solutions to the puzzle. (See below)
I just wanted to make it a better one, a more flexible one.
I posted the mail for just pointers/directions and not the answer itself!
(If you read my entire original mail, esp the last para)
I had subscribed to this group to learn perl. But I guess its more abt solving the issue rather than solving it the best possible way.

Anyways, maybe my presentation of the prob was wrong or maybe I was wrong in posting it. I shall take care of it going fwd.

Sorry ppl, for cluttering your mailboxes.
This one is the last.

Solutions:
for(my \$x=0;\$x<3;\$x++)
{
for(my \$y=0;\$y<3;\$y++)
{
print("Enter the value to save in the array : ");
\$input = <stdin>;
\$arr1[\$x][\$y] = \$input;
}
}
my \$m=0;
for(my \$i=2;\$i>=0;\$i--)
{
my \$n=0;
for(my \$j=2;\$j>=0;\$j--)
{

\$arr2[\$m][\$n] = \$arr1[\$i][\$j];
print ("\$arr2[\$m][\$n]");
\$n++;
}
\$m++;
}

or perhaps used a mathematical logic like:

#Changing the columns
\$a[0][0] +=\$a[0][2];
\$a[1][0] +=\$a[1][2];
\$a[2][0] +=\$a[2][2];
\$a[0][2] = \$a[0][0]-\$a[0][2];
\$a[1][2] = \$a[1][0]-\$a[1][2];
\$a[2][2] = \$a[2][0]-\$a[2][2];
\$a[0][0] = \$a[0][0]-\$a[0][2];
\$a[1][0] = \$a[1][0]-\$a[1][2];
\$a[2][0] = \$a[2][0]-\$a[2][2];
#Changing the rows
\$a[0][0] +=\$a[2][0];
\$a[0][1] +=\$a[2][1];
\$a[0][2] +=\$a[2][2];
\$a[2][0] = \$a[0][0]-\$a[2][0];
\$a[2][1] = \$a[0][1]-\$a[2][1];
\$a[2][2] = \$a[0][2]-\$a[2][2];
\$a[0][0] = \$a[0][0]-\$a[2][0];
\$a[0][1] = \$a[0][1]-\$a[2][1];
\$a[0][2] = \$a[0][2]-\$a[2][2];

"Charles K. Clarkson" <cclarkson@...> wrote:
Tabassum Shaikh wrote:

: I didnt say that it was a real life problem either.

It was implied. By not saying what you were doing,
you implied that this was a real life problem.

: I agreed that it was a puzzle.
:
: I didnt know that we couldnt post puzzles in here.

Of course you can post puzzles here. If you do post
a puzzle which looks just like homework and you don't
explain your post, don't be surprised that we land on
you like a ton of bricks. PBML posters are forbidden

You didn't have the patience to post a full
explanation. Why fault us for not having the patience
to confirm this wasn't homework?

Most of the people answering questions here
realize the importance of working out homework
problems for yourself. The very last thing we want to
do is mistakenly answer someone's homework and rob
them of a needed lesson.

HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html

---------------------------------

Visit your group "perl-beginner" on the web.

To unsubscribe from this group, send an email to:
perl-beginner-unsubscribe@yahoogroups.com