1. 程式人生 > >C語言for 循環 9*9 實現九九乘法表

C語言for 循環 9*9 實現九九乘法表

printf sha pre tdi c語言 for循環 clu ret blog

#include <stdio.h>

int main(void)
{
	//for循環實現9*9乘法表
	/*
	1*1=1
	1*2=2 2*2=4
	1*3=3 2*3=6 3*3=9
	*/
	int temp,i,j;
	
	for(i=1; i<10; i++){
		for(j=1;j<=i;j++){
			temp = j*i; //
			if(temp<10){
				printf("%d*%d= %d ",j,i,temp);
			}else{
				printf("%d*%d=%d ",j,i,temp);	
			}			
		}
		printf("\n");
	}
	return 0;
}

  

C語言for 循環 9*9 實現九九乘法表