/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
*/
package output;
/**
*
-
@author Renan
*/
public class Output {/**
-
@param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Output o = new Output();
o.go();
}
void go(){
int y = 7;
for( int x = 1; x < 8; x++){
y++;
if (x > 4) {
System.out.print(++y + " ");} if (y>14) { System.out.println(" x = " + x); break; }}}} -
@param args the command line arguments
Porque 13 15 e 6 a resposta ?.
Se x=1 y=8 então x=7 y=14.
O resultado ta última é X= 6 porque é y<14
Agora ++y ele não teria que pegar o valor de Y antes de chegar em X<8 que é X=7 onde Y = 14.
E depois pede ++y + < pega o valor de Y 14 e aumenta mais 1 onde fica 15.
Onde surgi esse número 13 ou minha lógica está errada, desculpe a pergunta simples mais estou aprendendo e estou no começo do livro ainda.