導航:首頁 > 編程語言 > java實現乘法表

java實現乘法表

發布時間:2022-04-17 12:16:17

java初學:如何實現這種格式的九九乘法表

主要循環代碼已給出,測試成功
for(intx=1;x<=9;x++){
for(intanull=2;anull<=x;anull++){判斷並

System.out.print(" ");
}
for(inty=x;y<=9;y++){輸出乘法表
System.out.print(y+"*"+x+"="+(x*y)+" ");
}

System.out.println();
}

樓上的我測試了下,跟樓主需求不一樣

② java 九九乘法表

肯定的啊.第二個程序循環
for (int j=1;j==i;j++){
System.out.print(i+"*"+j+"="+(i*j)+"\t");
}
i=1時,j=1,好吧,出來了1*1=1
j=2時,i==j不成立了,所以j不++了.所以j永遠是2了.永遠不等於,所以不會列印了.
i=2,3,4,5,6,7,8,9時
j開始等於1,結果j永遠不會等於i,所以j永遠是1了,後面的也就不會執行,不會列印了

③ JAVA初學:要怎麼實現這種九九乘法表格式

for (int i=1 ; i<=9 ; i++ ){


for ( int j = 1; j <=9 ; j++ )

System.out.print( i + "*" + j +"=" +i * j+ " ");


System.out.println();


}


④ JAVA乘法表怎麼寫

public class Multiplicaiton
{
public static void main(String[] args)
{
for (int i = 1; i <= 9; i++)
{
for(int n = 1; n <= i; n++)
{
System.out.print( i + " x " + n + " = " + i * n + " ");
}
System.out.println();
}
}
}

⑤ 怎麼用java編寫程序實現九九乘法表

代碼如下:

public class qct {

public static void main(String[] args)

{

int i=0;

int j=0;

for(i=1;i<=9;i++)

{ for(j=i;j<=9;j++)

System.out.print(i+"*"+j+"="+i*j+" ");

System.out.println();

}

}

}

(5)java實現乘法表擴展閱讀

importjava.lang.*;

import java.util.Arrays;

public class ChengFB

{

public static void main(String[] args)

{

int[] Num=new int[10];

for(int i=1;i<10;i++)

{

Num[i]=i;

}

for(int m=9;m>0;m--)

{

for(int j=9;j>=m;j--)

{

int Result;

Result=Num[m]*Num[j];

System.out.print(Num[j]+"*"+Num[m]+"="+Result+" ");

}

System.out.println();

}

}

public int Multi(int x,int y)

{

int temp;

temp=x*y;

return temp;

}

}

⑥ 編寫java程序九九乘法表用類來實現

public class MultiplyTest
{

public static void main(String[] args){

for(int i = 1; i <= 9; i++){
for(int j = 1; j <= i; j++){
System.out.print(new Member(i, j));
}
System.out.println();
}

}
}

class Member{
int num1;
int num2;
public Member(int num1, int num2){
this.num1 = num1;
this.num2 = num2;
}

public String toString(){
return num1 + "*" + num2 + "=" + num1* num2 + "\t";
}

}
手工寫的請採納

⑦ java編寫中文乘法表

兄弟,搞定了,復制直接用,放心,沒病毒。
package importcsv;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Date;
import java.util.HashMap;
import java.util.Stack;

public class DoSomeThing {
public static void main(String[] args) {
DoSomeThing re = new DoSomeThing();

int a = 0, b = 0, c = 0;
for (int i = 0; i < 9; i++) {
a = i + 1;
for (int j = 0; j < i + 1; j++) {
b = j + 1;
c = a * b;
System.out.print(re.rework(a) + "" + re.rework(b) + "得" + re.rework(c) + " ");
}
System.out.println(" ");
}
}
public Stack<Integer> transfer(int n) {
Stack<Integer> st = new Stack<Integer>();
int division = 0; // 余數
while (n >= 10) {
division = n % 10;
st.push(division);
n = n / 10;
}

st.push(n); // 將最高位壓棧

return st;
}

public String rework(Integer num) {
DoSomeThing tf = new DoSomeThing();
Stack<Integer> s = tf.transfer(num);
/*
* while(!s.empty()){ System.out.print(s.pop()); //測試語句 }
*/

HashMap<Integer, String> hp1 = new HashMap<Integer, String>(); // 第一個映射表
hp1.put(0, "零"); // 根據所在位的數值與中文對應
hp1.put(1, "一");
hp1.put(2, "二");
hp1.put(3, "三");
hp1.put(4, "四");
hp1.put(5, "五");
hp1.put(6, "六");
hp1.put(7, "七");
hp1.put(8, "八");
hp1.put(9, "九");

HashMap<Integer, String> hp2 = new HashMap<Integer, String>(); // 第二個映射表
hp2.put(2, "十"); // 根據所在位數,與中文對應
hp2.put(3, "百");
hp2.put(4, "千");
hp2.put(5, "萬");
hp2.put(6, "十萬");
hp2.put(7, "百萬");
hp2.put(8, "千萬");
hp2.put(9, "億");

String out = "";
while (!s.isEmpty()) {
int temp = s.pop();

if (s.size() == 0) {
if (temp != 0) {
out = out + hp1.get(temp);
}
} else {
if (temp == 0) {
out = out + hp1.get(temp);
} else {
out = out + hp1.get(temp) + hp2.get(s.size() + 1);
}
}
}
return out;
}
}

⑧ java九九乘法表編程代碼是什麼

package ch02;

public class TEST{

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)+" ");

}System.out.println();

}

}

}

測試結果 :

1*1=1

1*2=2 2*2=4

1*3=3 2*3=6 3*3=9

1*4=4 2*4=8 3*4=12 4*4=16

1*5=5 2*5=10 3*5=15 4*5=20 5*5=25

1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36

1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49

1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64

1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81

⑨ 用java編寫可以控制行列的乘法表

importjava.util.Scanner;

publicclassTest{
publicstaticvoidmain(String[]args){
Scannersc=newScanner(System.in);
System.out.println("輸入行:");
inth=sc.nextInt();
System.out.println("輸入列:");
intl=sc.nextInt();

System.out.println("*************************"+h+"行×"+l+"乘法口訣表*****************************");
for(intx=1;x<=h;x++){
for(inty=1;y<=l;y++){
if(y<=x){
System.out.print(y+"×"+x+"="+y*x+" ");//println改為print不換行輸出
}
}
System.out.println();//換行放在這里
}

System.out.println("*************************完整9×9乘法口訣表*****************************");
for(intx=1;x<=9;x++){
for(inty=1;y<=x;y++){
System.out.print(y+"×"+x+"="+y*x+" ");//println改為print不換行輸出
}
System.out.println();//換行放在這里
}
}
}

⑩ 用Java語言如何做一個九九乘法表

publicclassTest{
publicstaticvoidmain(String[]args){
for(intx=1;x<=9;x++){
for(inty=1;y<=x;y++){
System.out.print(y+"*"+x+"="+(x*y)+" ");
}
System.out.println();
}
}
}

閱讀全文

與java實現乘法表相關的資料

熱點內容
dns使用加密措施嗎 瀏覽:172
php獨立運行 瀏覽:530
手機sh執行命令 瀏覽:727
雲伺服器的角色 瀏覽:733
單片機頻率比例 瀏覽:840
我的世界伺服器如何關閉正版驗證 瀏覽:504
如何查roid伺服器上的 瀏覽:130
安卓手機主板如何撬晶元不掉電 瀏覽:249
php各個框架的優缺點 瀏覽:101
php1100生成數組 瀏覽:359
以後做平面設計好還是程序員好 瀏覽:552
雲伺服器應用管理 瀏覽:438
飢荒雲伺服器搭建過程 瀏覽:186
可編程式控制制器優點 瀏覽:99
壓縮垃圾車說明書 瀏覽:28
五輪書pdf 瀏覽:802
單片機定時流水中斷系統流水燈 瀏覽:701
u8如何連接伺服器配置 瀏覽:68
動力在於緩解壓力 瀏覽:867
報考科一用什麼app 瀏覽:346