Bienvenido a Internet ■Volver al BBS■ Hilo completo ▼Bajar▼

■ Este hilo se encuentra guardado en el archivo

Code (6 respuestas)

1 : Nameless@Passing through the lobby [SG] (*.singnet.com.sg) : 12/02/21(fri)23:28:32 ID:GgGoUQrG0

public void shuffle ()

{

int[] front = new int[cards.length/2];

for (int k = 0; k < front.length; k++)

front[k] = cards[k];

int[] back = new int[cards.length/2];

for (int k = 0; back.length; k++)

back[k] = cards[back.length + k];

int[] newCards = new int[cards.length]

int j = 0;

while (j < newCards.length)

{

if (k % 2 == 1)

newCards[k] = back[cards.length/2];

else

newCards[k] = front [k/2];

}

cards = newCards;

}

2 : Nameless@Passing through the lobby [CL] (*.vtr.net) : 12/02/21(fri)23:28:56 ID:uMh95Kz/0

hax my anus

3 : Nameless@Passing through the lobby [CL] (*.wom.cl) : 13/02/21(sat)12:33:13 ID:9KS2F+4sa

>>1
Nice code.

Wait, how do you shuffle in newCards if card.lenght is constant? Using always the same card from back[]?

4 : : 13/02/21(sat)15:37:59 ID:84a52DtRa

In the while loop why using a variable for de conditional that always will be the same? Wouldn't be more readable to just write "newCards.length > 0"?

5 : Nameless@Passing through the lobby [SG] (*.singnet.com.sg) : 16/02/21(tue)13:08:16 ID:G7ctNPRi0

>>3

Code Pen might be the best platform to test your question ???? http://codepen.io

6 : Nameless@Passing through the lobby [MX] (*.cablevision.net.mx) : 16/02/21(tue)16:02:11 ID:V3vGq+n30

too much javascript
1 KB

■ Este hilo se encuentra guardado en el archivo

weabot.py ver 0.10.9 Bienvenido a Internet BBS/IB