본문 바로가기
프로그래밍/자바의정석_4_연습문제

[4-8] 방정식 2x+4y=10의 모든 해를 구하시오. 단, x와 y는 정수이고 각각의 범위는 0<=x<=10, 0<=y<=10 이다.

by 므시칸곰틔군 2014. 8. 5.

public class ex_008 {

 // [4-8] 방정식 2x+4y=10의 모든 해를 구하시오. 단, x와 y는 정수이고 각각의 범위는 0<=x<=10, 0<=y<=10 이다.

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub

  for (int i = 0; i <= 10; i++) {
   for (int j = 0; j <= 10; j++) {

    if (((2 * i) + (4 * j)) == 10) {
     System.out.print("x  : " + i + "\t");
     System.out.println("y  : " + j);
    }

   }
  }
 }

}