domingo, 15 de fevereiro de 2009

MENSAGENS MISTURADAS PAG 16

Um programador Java curto é listado a seguir. Um bloco do programa está falando. Seu desafio é comparar o bloco de código candidato (à esquerda) com a saída que você veria se ele fosse inserido. Nem todas as linhas de saída serão usadas e algumas delas podem ser usadas mais de uma vez. Desenhe linhas conectando os blocos de código candidatos à saída de linha de comando correspondentes. (As respostas estão no final.)




package msgMisturadaPag16;

/**
*
* @author thiago_azeredo
*/
public class MenssagemMisturada {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

int x = 0;
int y = 0;
// Primeiro cruzamento !
while (x < 5){

// 1° Cruzamento RESPOSTA 00 11 21 32 42
//y = x - y;

// 2° cruzamento RESPOSTA 00 11 23 36 410
// y = y + x;

// 3° cruzamento RESPOSTA 02 14 25 36 47
// y = y + 2;
// if (y > 4){
// y = y - 1;
// }

// 4° cruzamento RESPOSTA 11 34 59
// x = x + 1;
// y = y + x;

// 5° cruzamento RESPOSTA 02 14 36 48
//if ( y < 5 ){

// x = x + 1;
// if (x < 3){
// x = x - 1;
// }
// }
// y = y + 2;


System.out.println(x + "" + y + "");
x = x + 1;
}

}

}

Nenhum comentário:

Postar um comentário