take a string = "abcdefgh";
reverse this without using any temp variables ;-)
-F
give me 30 -60 mins
Just post the output of the run, not the source code till
everone has a chance to attempt it.
thanks
-F
actually I am not sure, I remember this being asked in an interview
(with Cisco I think) and I did it at that time.
Let's start trying with NO temp variables and then if that is
impossible then we can use one.
as usual post the results first and then the code after everyone completes.
-F
Last edited by Punch Farce; 08-06-09 at 01:12 AM. Reason: Automerged Doublepost
Did you do it in c/c++, using pointers?
A simple yes/no will do? lol
funny output:
a e i m
b f j n
c g k o
d h l p
I was spoon fed this problem.
Last edited by Luke Skywalker; 08-06-09 at 01:26 AM. Reason: Automerged Doublepost
But can't recall the answer.
trying with unicode give 45 min more.
Last edited by Luke Skywalker; 08-06-09 at 01:32 AM. Reason: Automerged Doublepost
I am really really impressed with myself ;-)
I rememebered 3 lines of code I did in an interview 10 years back!
> !cc
cc rrr.c
> a.out
before = abcdefgh
after = hgfedcba
>
Don't give us complexion, Farce.![]()
I think I need to sleep.
My program had change & giving me this:
p p p p
p p p p
p p p p
p p p p
i = -1;
n = 0;
j = 0;
k = 0;
l = 0;
while (n <17)
{
if (i < 3)
{
i++;
k = 0;
}
else
{
l++;
k = l;
}
for (j = 0; j<= i-l; j++)
{
char2DArray[i-j][k]=charArray[n];
n++;
k++;
}
}
Last edited by Punch Farce; 08-06-09 at 01:55 AM. Reason: Automerged Doublepost
are you guys discussing a different program, i jus got the answer for the first one ...
should i post it now ??
Last edited by Pri_dm; 08-06-09 at 02:01 AM. Reason: Automerged Doublepost
class Math
{
public static void main(String[] args)
{
char[] charArray={'a','b','c','d','e','f','g','h','i','j' ,'k','l','m','n','o','p'};
char[][] char2DArray=new char[4][4];
char[][] a=new char[4][4];
for(int x=0; x<charArray.length; x++){
for(int d=0; d<char2DArray.length; d++){
for(int b=0; b<char2DArray[d].length; b++){
char2DArray[b][d] = (char)charArray[x];
}}}
for(int i = 0; i <= 3; i++) {
System.out.print("");
for(int j = 0; j <= 3; j++) {
System.out.print(" " + char2DArray[i][j]);
}
System.out.println("");
}
System.out.println();
}
}
What the hell had happened that this is not copying?
@Farce can I pm you my poetry again?
History is on the move,my friends.Those who cannot keep up will be left behind, to watch from distance.And those who stand in its way will not watch at all.http://windows7sins.org/
People are going to tell stories about me none of which change who I really am.
There are currently 1 users browsing this thread. (0 members and 1 guests)