C언어

[C] 구구단 코드

Jeong's FP 2018. 3. 23. 15:19





public class 구구단 {
	public static void main (String[] args){
		// 구구단 세로로 출력하기 이건 뒷자리가 바뀌면서 배열되는거임
		for(int a=2; a<=9; a++){
			for(int b=1; b<=9; b++){
				System.out.println( a + " * " + b + " = " + a*b );	
			}
			System.out.println();
		}
		{	// 구구단 가로로 출력하기 즉 앞자리가 바뀌면서 배열되는거임
			for (int c=1; c<=9; c++){
				for (int d=2; d<=9; d++){
					System.out.print(c + " * " + d + " = " + c*d + "\t")
				}
				System.out.println();	
			}
		}
	}
}