1. 程式人生 > >C語言/C++/JAVA列印九九乘法表

C語言/C++/JAVA列印九九乘法表

C/C++程式碼:

	printf("九九乘法表:\n");
	for (int i = 1; i < 10; i++){
		for (int j = 1; j <= i; j++)
			printf("%d * %d = %d \t", j, i, j*i);
		printf("\n");
	}

JAVA程式碼:


public class cfb {
public static void main(String[] args){
	System.out.println("九九乘法表:");
	for(int i=1;i<10;i++){
		for(int j=1;j<=i;j++)
			System.out.print(j+"*"+i+"="+i*j+"\t");
		System.out.println();
	}
}
}