谁能用最简便的方法编写乘法口诀表 大家都交流下,看看大家的编程思想 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这样行不?for (int i=1; i<=9; i++) { for (int j=1; j<=i; j++) { System.out.printf("%2d ", i*j); } System.out.println("");} 这样行不?System.out.print( " 1 \n" + " 2 4 \n" + " 3 6 9 \n" + " 4 8 12 16 \n" + " 5 10 15 20 25 \n" + " 6 12 18 24 30 36 \n" + " 7 14 21 28 35 42 49 \n" + " 8 16 24 32 40 48 56 64 \n" + " 9 18 27 36 45 54 63 72 81 \n"); import java.util.*;public class MultipleTable{ public static void main(String[]args) { MultipleTable mt = new MultipleTable(); int initNum = 9; int res = 0; for(int i = 1; i<=initNum; i++) { for(int j = 1;j<= i;j++) { res = i * j; mt.printFormula(i,j,res); } System.out.print("\n"); } } public void printFormula(int i,int j,int res) { System.out.print(i+ "*"+j+"="+res + " "); }} int i ,j ; for( i = 1,j = 1 ; i <= 9 ; j++){ System.out.print(j + "*" + i + "=" + i*j + " "); if(j == i){ j = 0; i++; System.out.println(); continue; } } class 九九{int n; public 九九(int n) {this.n=n;} void a() {int i,j; for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { System.out.print(j+"*"+i+"="+j*i+"\t"); if(j==i) {System.out.println();} } } } } public class 九九表 { public static void main(String args[]) {九九 p1=new 九九(9); p1.a(); } } 再给你缩下水 public class biao { 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+"\t"); if(j==i) {System.out.println();} } } }} 不好意思continue; 去掉 递归九九public class Test2 { public static void main(String[] args) { table99(1, 1); } public static void table99(int row, int col) { if(col <= 9) { System.out.printf("%1d*%1d=%2d", row, col, row*col); String separator = ""; if(row == col) { row = 1; col = col + 1; separator = "\n"; }else{ row = row + 1; separator = " "; } System.out.print(separator); table99(row, col); } }} System.out.println("乘法口诀表 "); for(int i = 1;i<10;i++) { for(int j = 1;j<i+2;j++) { if(j==i+1) System.out.println(); else System.out.print(i*j+","); } } 综合比较一下,还是zephyr_cc() 的算法最简单 :) zephyr_cc() 的算法岂止简单哦,简直妙不可言啊public static void main(String[] args) { for(int i = 1; i < 10; i++) { for(int j = 1; j <= i; j++) { System.out.print(i + "*" + j + " = " + i * j + \t); } System.out.println(); }}献丑哈 int i=1;while(i<=9){ j=1; if(j<=i) { printf("%d*%d=%d",i,j,i*j); } else { j++; } i++;} 这样行不?System.out.print( " 1 \n" + " 2 4 \n" + " 3 6 9 \n" + " 4 8 12 16 \n" + " 5 10 15 20 25 \n" + " 6 12 18 24 30 36 \n" + " 7 14 21 28 35 42 49 \n" + " 8 16 24 32 40 48 56 64 \n" + " 9 18 27 36 45 54 63 72 81 \n");这个最好,你们还得循环那么多次,这个效率最高. for(int i=1;i<=9;i++){ for(int j=1;j<=i;j++) { System.out.print(j+"*"+i+"="+j*i+" "); } System.out.println();} class 乘法表{ public static void main (String[] args) { for(int i=1;i<10;i++) { for(int j=1;j<10;j++) { if(i*j<10) { System.out.print("i*j="+" "+i*j+" "); } else { System.out.print("i*j="+i*j+" "); } if(i==j) { System.out.println("");break; } } } }} 关于UTF-8转码 Java中任何时候this均不能引用成员变量? 大家给我帮我写个例子 用java语言编写插入大对象到oracle!高分 在jsp页面调用包中类的方法出错的问题 检验大家的finally学的程度的一段代码,你能全部答对吗? 抽象类与static和final 求教:new Scanner(System.in) 编译出错 三个java文件怎么一起编译? 关于jar的打包问题 inbox里的message标志为DELETED 后在垃圾箱还是还在inbox 里? Aglet运行时出错,求救 关于转换的问题 valueOf() 和 toString() 的区别
for (int j=1; j<=i; j++) {
System.out.printf("%2d ", i*j);
}
System.out.println("");
}
System.out.print(
" 1 \n" +
" 2 4 \n" +
" 3 6 9 \n" +
" 4 8 12 16 \n" +
" 5 10 15 20 25 \n" +
" 6 12 18 24 30 36 \n" +
" 7 14 21 28 35 42 49 \n" +
" 8 16 24 32 40 48 56 64 \n" +
" 9 18 27 36 45 54 63 72 81 \n");
public class MultipleTable
{ public static void main(String[]args)
{ MultipleTable mt = new MultipleTable(); int initNum = 9;
int res = 0;
for(int i = 1; i<=initNum; i++)
{ for(int j = 1;j<= i;j++)
{ res = i * j;
mt.printFormula(i,j,res);
}
System.out.print("\n");
}
}
public void printFormula(int i,int j,int res)
{ System.out.print(i+ "*"+j+"="+res + " ");
}
}
for( i = 1,j = 1 ; i <= 9 ; j++){
System.out.print(j + "*" + i + "=" + i*j + " ");
if(j == i){
j = 0;
i++;
System.out.println();
continue;
}
}
{int n;
public 九九(int n)
{this.n=n;}
void a()
{int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(j+"*"+i+"="+j*i+"\t");
if(j==i) {System.out.println();}
}
}
} }
public class 九九表
{
public static void main(String args[])
{九九 p1=new 九九(9);
p1.a();
}
}
public class biao
{
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+"\t");
if(j==i) {System.out.println();}
}
}
}
}
continue; 去掉
public static void main(String[] args) {
table99(1, 1);
}
public static void table99(int row, int col) {
if(col <= 9) {
System.out.printf("%1d*%1d=%2d", row, col, row*col);
String separator = "";
if(row == col) {
row = 1;
col = col + 1;
separator = "\n";
}else{
row = row + 1;
separator = " ";
}
System.out.print(separator);
table99(row, col);
}
}
}
{
for(int j = 1;j<i+2;j++)
{
if(j==i+1) System.out.println();
else
System.out.print(i*j+",");
}
}
public static void main(String[] args) {
for(int i = 1; i < 10; i++) {
for(int j = 1; j <= i; j++) {
System.out.print(i + "*" + j + " = " + i * j + \t);
}
System.out.println();
}
}
献丑哈
while(i<=9)
{
j=1;
if(j<=i)
{
printf("%d*%d=%d",i,j,i*j);
}
else
{
j++;
}
i++;
}
System.out.print(
" 1 \n" +
" 2 4 \n" +
" 3 6 9 \n" +
" 4 8 12 16 \n" +
" 5 10 15 20 25 \n" +
" 6 12 18 24 30 36 \n" +
" 7 14 21 28 35 42 49 \n" +
" 8 16 24 32 40 48 56 64 \n" +
" 9 18 27 36 45 54 63 72 81 \n");这个最好,你们还得循环那么多次,这个效率最高.
{
for(int j=1;j<=i;j++)
{
System.out.print(j+"*"+i+"="+j*i+" ");
}
System.out.println();
}
{
public static void main (String[] args)
{
for(int i=1;i<10;i++)
{
for(int j=1;j<10;j++)
{
if(i*j<10)
{
System.out.print("i*j="+" "+i*j+" ");
}
else
{
System.out.print("i*j="+i*j+" ");
}
if(i==j)
{
System.out.println("");break;
}
}
}
}
}