九九乘法表程序设计
C
----------------------------------------------------
//九九乘法表
#include <stdio.h>
main(){
int i,j;
for(i=1;i<=9;i++){
for(j=1;j<=9;j++){
if(i>=j)
printf("%d*%d=%d",j,i,j*i);
if(j*i<10)
printf(" ");
else
printf(" ");
}
printf("\n");
}
}
--------------------------------------------------------------
Java
---------------------------------------------------------------
//九九乘法表
public class chengfa {
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+"="+j*i);
if(i*j<10){ //处理乘机超过个位时不对齐的问题
System.out.print(" ");
}else{
System.out.print(" ");
}
}
System.out.println(" ");
}
}
}
---------------------------------------------------------------------
C++
---------------------------------------------------------------------
#include <iostream>
using namespace std;
int main()
{
int i,j;
for(i=1;i<=9;i++){
for(j=1;j<=9;j++){
if(i>=j)
cout <<j<<"*"<<i<<"="<<j*i;
if(j*i<10)
cout <<(" ");
else
cout <<(" ");
}
cout <<("\n");
}
}
---------------------------------------------------------------------
C#
---------------------------------------------------------------------
static void Main(string[] args)
{
//乘法口决
int i, j;
for (i = 1; i <10; i++)
{
for (j = 1; j <=i; j++)
{
if (j <= i)
{
if (i * j < 10)
{
Console.Write(j + "*" + i + "=" + j * i + " ");
}
else
{
Console.Write(j + "*" + i + "=" + j * i + " ");
}
}
if(i==j)
{
Console.Write("\n");
}
}
}
Console.ReadKey();
}