자바로 구구단 소스를 작성해보았습니다.
continue, break문을 사용하지 않고, 루프도 중복 루프를 사용하지 않고 하나의 loop문을 사용한 구구단입니다.
Below java source code prints out multiplication table.
It does not use nested-loop. It only uses one for-loop.
public class gugudan {
public static void main(String args[]){
System.out.println("구구단입니다.");
int i = 1,b = 1;
while ( i < 10 ) {
if( b == 10 ) {
i+=1;
b=1;
}
if ( i != 10 ) {
System.out.println(i+"*"+b+"="+i*b);
b++;
}
}
}
}
[ Java / 자바 ] 시스템 독립적인 라인 구분자 (0) | 2015.04.27 |
---|---|
[ Java / 자바 ] 현재 날짜 및 시간 구하기 (0) | 2015.04.27 |
[알고리즘/문제풀이] CodingBat Array-3 fix34 (0) | 2015.04.22 |
[알고리즘/문제풀이] CodingBat Array-3 maxSpan (0) | 2015.04.22 |
[알고리즘/문제풀이] CodingBat Logic-2 noTeenSum (0) | 2015.04.22 |