'Programming/JAVA'에 해당되는 글 2건

  1. 2013.05.03 I/O ppt 자료
  2. 2012.03.02 for문으로 구구단 출력하기
2013. 5. 3. 03:11


입출력 io.pptx


보면 기초에 대한 도움은 될 듯


'Programming > JAVA' 카테고리의 다른 글

for문으로 구구단 출력하기  (0) 2012.03.02
Posted by 라티아

 

package helloWorld;
public class HelloWorld

public static void main(String[] args) {
  int total = 0;
  for(int i = 2; i<=9;i++){
   for(int j = 1; j<=9;j++){
    total = i*j;
    System.out.println(i+"x"+j +"="+ total);
    total = 0;//total 값이 누적되지 않도록 초기화
   }
  }
 }
}

구구단의 핵심은 for문안에 for문이 돈다는 겁니다
바깥쪽 for문이 실행되면 안에 있는 for문이 조건식을 모두 완료해야 바깥쪽 for문으로 다시 이동합니다
위의 예제로 보면 i 가 2일때 j는 1,2,3,4,5,6,7,8,9가 되는 식입니다

'Programming > JAVA' 카테고리의 다른 글

I/O ppt 자료  (0) 2013.05.03
Posted by 라티아
이전버튼 1 이전버튼