## Eliana

BAN USERI will tell u later >3

- -2of 4 votes

AnswersLook at the following pseudo-code, which computes the n-th Fibonacci number:

- Eliana in United States for interviews

int fibonacci(int n)

{

if (n == 0)

{

print(0)

return 0

}

if (n == 1)

{

print(1)

return 1

}

return fibonacci(n - 1) + fibonacci(n - 2)

}

If one calls fibonacci(3), then the following will happen:

* fibonacci(3) calls fibonacci(2) and fibonacci(1) (the first call).

* fibonacci(2) calls fibonacci(1) (the second call) and fibonacci(0).

* The second call of fibonacci(1) prints 1 and returns 1.

* fibonacci(0) prints 0 and returns 0.

* fibonacci(2) gets the results of fibonacci(1) and fibonacci(0) and returns 1.

* The first call of fibonacci(1) prints 1 and returns 1.

* fibonacci(3) gets the results of fibonacci(2) and fibonacci(1) and returns 2.

In total, 1 will be printed twice and 0 will be printed once.

We want to know how many times 0 and 1 will be printed for a given integer N.

INPUT

The first line contains an integer T, denoting the number of test cases.

The next T lines contain an integer N.

OUTPUT

For each test case, print one line of output which contains 2 integers separated by a space. The first integer is the number of times 0 is printed. The second integer is the number of times 1 is printed.

CONSTRAINTS

1 <= T <= 50

0 <= N <= 40

SAMPLE INPUT

2

0

3

SMAPLEOUTPUT

1 0

1 2| Report Duplicate | Flag | PURGE

Informatica iOS Developer C++ - -2of 2 votes

AnswersThe way a Knight Given a chessboard, consisting of n×n cells, several of them are cut. Find the path of minimum length for a Knight from one cell to another. The Knight can’t go through cut cells.

- Eliana in United States for interviews

Specifications

Input

The first row is set to the number n (2 ≤ n ≤ 50). Each of the next n lines contains n symbols. The symbol # denotes the cut cell, the point - not cut cell, the symbol @ denotes the initial and final cell of the Knight's path (the chessboard contains two such characters).

Output If the path can not be constructed, print "Impossible". Otherwise display the same map as the input, but check all Knight intermediate positions with symbol @. Example

Example input

5

.....

.@@..

.....

.....

.....

5

@..@.

..##.

.....

.....

.....

5

@....

..#..

.#...

.....

....@

Example output

Sample 1

...@.

.@@..

....@

.....

.....

Sample 2

@..@.

..##.

.@..@

..@..

@....

Sample 3

Impossible| Report Duplicate | Flag | PURGE

Informatica iOS Developer C - -6of 6 votes

AnswersThis code is written in vb.net language for XO game between two players , TIC TOE

- Eliana in United States for personnel interview

I WANT A LITTLE EXPLANATION FOR EACH MAIN LINE IN THE CODE ..

Here is the cod>>

>

>

Public Class Form1

Dim player1, player2 As String

Dim CurrPlayer As Char

Dim winner As Char

Dim win As Boolean = False

Dim Endgame As Boolean = False

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

CurrPlayer = "O"

player1 = InputBox("First Player Name:")

player2 = InputBox("Second Player Name:")

lblPlayer1.Text = lblPlayer1.Text + player1

lblPlayer2.Text = lblPlayer2.Text + player2

End Sub

Public Function turn() As Char

If CurrPlayer = "X" Then

CurrPlayer = "O"

ElseIf CurrPlayer = "O" Then

CurrPlayer = "X"

End If

Return CurrPlayer

End Function

Public Function CheckWin() As Boolean

If btn1.Text <> "" And btn1.Text = btn2.Text And btn2.Text = btn3.Text Then

winner = CurrPlayer

win = True

ElseIf btn1.Text <> "" And btn1.Text = btn5.Text And btn5.Text = btn9.Text Then

winner = CurrPlayer

win = True

ElseIf btn1.Text <> "" And btn1.Text = btn4.Text And btn4.Text = btn7.Text Then

winner = CurrPlayer

win = True

ElseIf btn2.Text <> "" And btn2.Text = btn5.Text And btn5.Text = btn8.Text Then

winner = CurrPlayer

win = True

ElseIf btn3.Text <> "" And btn3.Text = btn5.Text And btn5.Text = btn7.Text Then

winner = CurrPlayer

win = True

ElseIf btn3.Text <> "" And btn3.Text = btn6.Text And btn6.Text = btn9.Text Then

winner = CurrPlayer

win = True

ElseIf btn4.Text <> "" And btn4.Text = btn5.Text And btn5.Text = btn6.Text Then

winner = CurrPlayer

win = True

ElseIf btn7.Text <> "" And btn7.Text = btn8.Text And btn8.Text = btn9.Text Then

winner = CurrPlayer

win = True

End If

Return win

End Function

Public Sub newGame()

For Each c As Control In Me.Controls

If c.GetType Is GetType(Button) Then

c.Text = ""

End If

Next

CurrPlayer = "O"

win = False

End Sub

Public Sub displayWinner()

If CheckWin() Then

If CurrPlayer = "X" Then

MessageBox.Show("Congratulations, the winner is " + player1, "Congratulations", MessageBoxButtons.OK, MessageBoxIcon.Information)

newGame()

Else

MessageBox.Show("Congratulations, the winner is " + player2, "Congratulations", MessageBoxButtons.OK, MessageBoxIcon.Information)

newGame()

End If

End If

End Sub

Public Sub CheckEven()

Dim empty As Boolean = False

For Each c As Control In Me.Controls

If c.GetType Is GetType(Button) Then

If c.Text = "" Then

empty = True

End If

End If

Next

If empty <> True Then

MessageBox.Show("Players are Even", "Neutral Game", MessageBoxButtons.OK, MessageBoxIcon.Information)

newGame()

End If

End Sub

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click

If btn1.Text = "" Then

btn1.Text = turn()

displayWinner()

CheckEven()

End If

End Sub

Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click

If btn2.Text = "" Then

btn2.Text = turn()

displayWinner()

CheckEven()

End If

End Sub

Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click

If btn3.Text = "" Then

btn3.Text = turn()

displayWinner()

CheckEven()

End If

End Sub

Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click

If btn4.Text = "" Then

btn4.Text = turn()

displayWinner()

CheckEven()

End If

End Sub

Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click

If btn5.Text = "" Then

btn5.Text = turn()

displayWinner()

CheckEven()

End If

End Sub

Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click

If btn6.Text = "" Then

btn6.Text = turn()

displayWinner()

End If

End Sub

Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click

If btn7.Text = "" Then

btn7.Text = turn()

displayWinner()

CheckEven()

End If

End Sub

Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click

If btn8.Text = "" Then

btn8.Text = turn()

displayWinner()

CheckEven()

End If

End Sub

Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click

If btn9.Text = "" Then

btn9.Text = turn()

displayWinner()

CheckEven()

End If

End Sub

End Class| Report Duplicate | Flag | PURGE

Epic Systems Software Architect - 0of 0 votes

AnswersLook at the following pseudo-code, which computes the n-th Fibonacci number:

- Eliana in United States for games developing

int fibonacci(int n)

{

if (n == 0)

{

print(0)

return 0

}

if (n == 1)

{

print(1)

return 1

}

return fibonacci(n - 1) + fibonacci(n - 2)

}

If one calls fibonacci(3), then the following will happen:

* fibonacci(3) calls fibonacci(2) and fibonacci(1) (the first call).

* fibonacci(2) calls fibonacci(1) (the second call) and fibonacci(0).

* The second call of fibonacci(1) prints 1 and returns 1.

* fibonacci(0) prints 0 and returns 0.

* fibonacci(2) gets the results of fibonacci(1) and fibonacci(0) and returns 1.

* The first call of fibonacci(1) prints 1 and returns 1.

* fibonacci(3) gets the results of fibonacci(2) and fibonacci(1) and returns 2.

In total, 1 will be printed twice and 0 will be printed once.

We want to know how many times 0 and 1 will be printed for a given integer N.

INPUT

The first line contains an integer T, denoting the number of test cases.

The next T lines contain an integer N.

OUTPUT

For each test case, print one line of output which contains 2 integers separated by a space. The first integer is the number of times 0 is printed. The second integer is the number of times 1 is printed.

CONSTRAINTS

1 <= T <= 50

0 <= N <= 40

SAMPLE INPUT

2

0

3

SMAPLEOUTPUT

1 0

1 2| Report Duplicate | Flag | PURGE

Akamai Computer Scientist C++ - 0of 0 votes

AnswersIf you look at the following pseudo-code, which computes the n-th Fibonacci number:

- Eliana in United States for games developing

int fibonacci(int n)

{

if (n == 0)

{

print(0)

return 0

}

if (n == 1)

{

print(1)

return 1

}

return fibonacci(n - 1) + fibonacci(n - 2)

}

If one calls fibonacci(3), then the following will happen:

* fibonacci(3) calls fibonacci(2) and fibonacci(1) (the first call).

* fibonacci(2) calls fibonacci(1) (the second call) and fibonacci(0).

* The second call of fibonacci(1) prints 1 and returns 1.

* fibonacci(0) prints 0 and returns 0.

* fibonacci(2) gets the results of fibonacci(1) and fibonacci(0) and returns 1.

* The first call of fibonacci(1) prints 1 and returns 1.

* fibonacci(3) gets the results of fibonacci(2) and fibonacci(1) and returns 2.

In total, 1 will be printed twice and 0 will be printed once.

We want to know how many times 0 and 1 will be printed for a given integer N.

INPUT

The first line contains an integer T, denoting the number of test cases.

The next T lines contain an integer N.

OUTPUT

For each test case, print one line of output which contains 2 integers separated by a space. The first integer is the number of times 0 is printed. The second integer is the number of times 1 is printed.

CONSTRAINTS

1 <= T <= 50

0 <= N <= 40

SAMPLE INPUT

2

0

3

SMAPLEOUTPUT

1 0

1 2| Report Duplicate | Flag | PURGE

Akamai Computer Scientist C++ - 1of 1 vote

AnswersThe way a Knight

- Eliana in United States for games developing

Given a chessboard, consisting of n×n cells, several of them are cut. Find the path of minimum length for a Knight from one cell to another. The Knight can’t go through cut cells.

Specifications

Input

The first row is set to the number n (2 ≤ n ≤ 50). Each of the next n lines contains n symbols. The symbol # denotes the cut cell, the point - not cut cell, the symbol @ denotes the initial and final cell of the Knight's path (the chessboard contains two such characters).

Output If the path can not be constructed, print "Impossible". Otherwise display the same map as the input, but check all Knight intermediate positions with symbol @.

Example

Example input

5

.....

.@@..

.....

.....

.....

5

@..@.

..##.

.....

.....

.....

5

@....

..#..

.#...

.....

....@

Example output

Sample 1

...@.

.@@..

....@

.....

.....

Sample 2

@..@.

..##.

.@..@

..@..

@....

Sample 3

Impossible| Report Duplicate | Flag | PURGE

Akamai Computer Scientist C

Run time error after I enhanced the code

...

#include<stdio.h>

int fib(int n);

int count0,count1;

int main()

{

int n,T;

//int i;

scanf("%d",&T);

while(T>=1 && T<=5)

{

count0=0;

count1=0;

scanf("%d",&n);

fib(n);

printf("%d %d\n",count0,count1);

}

}

int fib(int n)

{

if(n==0)

{

count0++;

return 0;

}

if(n==1)

{

count1++;

return 1;

}

return (fib(n-1)+fib(n-2));

}

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

stop making comments cuz im not gonna stop posting questions :P

- Eliana December 25, 2013really stupid , btw iam an architect engineer , iam learning c and c++ for fun :) .. so calm ur self down bb ..

now who is the pathetic lolll