C语言实现九九乘法口诀:
#includevoid main()
{
int i,j;
for(i=0;i<=9;i++)
{
for(j=1;j<=i;j++)
printf("%d * %d = %d\t",i,j,i*j);
printf("\n");
}
}
java实现九九乘法口诀:
public class mutiplyDemo {
public static void main(String[] args)
{
for (int i = 1;i <=9;i++ )
{
for(int j =1;j <= i;j++){
System.out.print(j + "*" + i +"=" + i*j +"\t");
}
System.out.println();
}
}
}
scala实现九九乘法口诀:
object multiply_2 {
def main(args: Array[String]): Unit = {
(
for (
i <- 1 to 9;
j <- 1 to i;
ss = s"$j * $i = ${i * j}\t"
)yield {
if (j ==i) s"$ss\n" else ss
}).foreach(print)
}
}
使用python实现九九乘法口诀:
i = 1
while i <= 9:
j = 1
while j <= i:
k = i * j
print("%d * %d == %d\t"%(i,j,k),end = "")
j += 1
print("")
i += 1