① 怎麼用java輸出九九乘法表
Java 技術具有卓越的通用性、高效性、平台移植性和安全性,廣泛應用於PC、數據中心、游戲控制台、科學超級計算機、行動電話和互聯網,同時擁有全球最大的開發者專業社群。
② JAVA輸出99乘法表
public class MultiplicationTable {
public static void main(String[] args) {
for (int i = 1 ; i <= 9 ; i++){
for (int j = 1 ; j <= i ; j++){
System.out.print(i + "*" + j + "=" + i * j + " ");
}
System.out.println();
}
}
}
執行效果一:
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81
倒置的九九乘法表
public class ResupinateMultiplicationTable {
public static void main(String[] args) {
for (int i = 9 ; i >= 1 ; i--){
for (int j = i ; j >= 1 ; j--) {
System.out.print(i + "*" + j + "=" + i * j + " ");
}
System.out.println();
}
}
}
執行效果二:
9*9=81 9*8=72 9*7=63 9*6=54 9*5=45 9*4=36 9*3=27 9*2=18 9*1=9
8*8=64 8*7=56 8*6=48 8*5=40 8*4=32 8*3=24 8*2=16 8*1=8
7*7=49 7*6=42 7*5=35 7*4=28 7*3=21 7*2=14 7*1=7
6*6=36 6*5=30 6*4=24 6*3=18 6*2=12 6*1=6
5*5=25 5*4=20 5*3=15 5*2=10 5*1=5
4*4=16 4*3=12 4*2=8 4*1=4
3*3=9 3*2=6 3*1=3
2*2=4 2*1=2
1*1=1
③ Java語言輸出倒九九乘法表(中文版)
import java.util.Scanner;
public class test{
private static String toCNNumber(int num) {
String temp[]={"一","二","三","四","五","六","七","八","九","十"},str="";
if (num>=1&&num<=9) {
str = temp[num-1];
}else if(num>=10&&num<=99){
if (num % 10 == 0) {
str =temp[num/10-1]+temp[temp.length-1];
}else{
if(num / 10==1){
str = temp[temp.length-1]+temp[num%10-1];
}else{
str = temp[num/10-1]+temp[temp.length-1]+temp[num%10-1];
}
}
}
return str;
}
public static void main(String[] args) {
for (int i = 9; i >= 1; i--) {
for (int j = i; j >= 1; j--) {
System.out.print(toCNNumber(i)+toCNNumber(j)+"得"+toCNNumber(i*j)+"\t");
}
System.out.println("");
}
}
}
④ 用java實現三種方法循環輸出九九乘法表:
for循環的結構:for(表達式 1;表達式 2;表達式 3) { 循環體 }
表達式 1:一般為賦值表達式;
表達式 2:一般為關系表達式或邏輯表達式;
表達式 3:一般為賦值表達式或自增、自減表達式,用以修改循環變數的值。
while循環的結構: while(表達式) 循環體
1、while 是C語言中的關鍵字;
2、圓括弧中的表達式可以是C語言中任意合法的表達式,不能為空,用它來控 制循環體是否執行;
3、循環體是一條語句,若需要使用多條語句,應使用復合語句(用{ }括起來);
4、若條件開始直接為假,則直接跳出循環。
do...while語句為先執行後判斷表達式的值。
1、do 是C語言的關鍵字,必須和while一起使用;
2、循環由do開始,由while結束;
3、循環體是一條語句,若需要使用多條語句,應使用復合語句(用{ }括起來);
4、圓括弧中的表達式可以是C語言中任意合法的表達式,不能為空,用它來控 制循環體是否執行;
(4)輸出99乘法表java擴展閱讀:
一般形式為:
for(單次表達式;條件表達式;末尾循環體)
{
中間循環體;
}
其中,表示式皆可以省略,但分號不可省略,因為「;」可以代表一個空語句,省略了之後語句減少,即為語句格式發生變化,則編譯器不能識別而無法進行編譯。
for循環小括弧里第一個「;」號前為一個為不參與循環的單次表達式,其可作為某一變數的初始化賦值語句, 用來給循環控制變數賦初值; 也可用來計算其它與for循環無關但先於循環部分處理的一個表達式。
倆「;」號之間的條件表達式是一個關系表達式, 其為循環的正式開端,當條件表達式成立時執行中間循環體。
執行的中間循環體可以為一個語句,也可以為多個語句,當中間循環體只有一個語句時,其大括弧{}可以省略,執行完中間循環體後接著執行末尾循環體 。
執行末尾循環體後將再次進行條件判斷,若條件還成立,則繼續重復上述循環,當條件不成立時則跳出當下for循環。
Pascal語言中的for循環:
for 循環變數:=初值 to/downto 終值 do
begin
循環體
end;
循環變數從起點到終點每次加1或減1(to 為加1,downto為減1)。
Pascal
while <條件> do <語句>
意為當條件符合時,接著做下面的語句;不符合時,退出循環。
C
do <語句> while(<條件>);
while(<條件>) <語句>;
C++
while(<條件>) <語句>;
do <語句> while(<條件>);
Java
while(<條件>) {<語句;>}
do {<語句;>} while(<條件>);
二者的區別是do-while最少會被執行一次。
循環中可以使用continue結束當前循環,回到循環開始處開始下一次循環。也可以用break跳出整個循環。
javascript
JavaScript中while循環的目的是為了反復執行語句或代碼塊。
只要指定條件為true,循環就可以一直執行代碼塊。
JavaScript中while循環的語法如下:
while (<條件>) {需執行的代碼 };
do {需執行的代碼 } while (<條件>);
注意:do...while 循環是 while 循環的變種。該循環程序在初次運行時會首先執行一遍其中的代碼,然後當指定的條件為 true 時,它會繼續這個循環。所以可以這么說,do...while 循環為執行至少一遍其中的代碼,即使條件為 false,因為其中的代碼執行後才會進行條件驗證。
while 循環是 php 中最簡單的循環類型。它和 C 語言中的 while 表現得一樣。語法如下:
while(expr){
statement
}
⑤ 怎麼編寫Java程序列印九九乘法表
用兩個for循環,一個參數遞增,另一個參數遞減,代碼如下:
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();
}
運行結果如下:
(5)輸出99乘法表java擴展閱讀:
Java中有三種主要的循環結構:
1、while循環
while是最基本的循環,它的結構為:
while( 布爾表達式 ) {
//循環內容}
只要布爾表達式為 true,循環就會一直執行下去。
2、do…while循環
對於 while 語句而言,如果不滿足條件,則不能進入循環。但有時候我們需要即使不滿足條件,也至少執行一次。
do…while 循環和 while 循環相似,不同的是,do…while 循環至少會執行一次。
do {
//代碼語句}while(布爾表達式);
3、for循環
for循環執行的次數是在執行前就確定的。語法格式如下:
for(初始化; 布爾表達式; 更新) {
//代碼語句}
Oracle官方API介面-Java™ Platform, Standard Edition 7API Specification
W3cSchool-Java 循環結構 - for, while 及 do…while
⑥ 用Java代碼實現輸出乘法口訣表有幾種方法
用Java程序實現九九乘法口訣表,可以用for()循環的方法來實現,代碼如下:
/**
*
*用java實現九九乘法表
*for()循環
*
*/
{
publicstaticvoidmain(String[]args){
//外層循環控制行數,9行。
//內存循環控制列數、數量。
for(inti=1;i<=9;i++)
{
for(intj=1;j<=i;j++)
{
System.out.print(i+"*"+j+"="+(i*j)+" ");
}
//換行顯示
System.out.println();
}
}
}
⑦ Java列印九九乘法表,要下面在這種格式
import java.util.Scanner;
/**
* @Author: Cool_Wu
* @Date: 2020-11-07 21:31
*/
public class Test{
public static void main(String[] args){
System.out.println("請輸入一個1~9之間的整數:");
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
for(int x = 1; x <= n; x++){
for(int y = 1; y <= x; y++){
int z = x * y;
String s = "";
if (z < 10){
s = z + " ";
}else {
s = z + "";
}
System.out.print(y +"×"+ x + "=" + s + " ");
}
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();
}
}
}
(8)輸出99乘法表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初學者,怎麼在命令符中輸出九九乘法表請把代碼給我謝謝。
在找的到位置新建 Demo.java.內容如下,也就是9*9的代碼
public class Demo
{
public static void main(String[] args)
{
int x,y;
for(x = 0;x <= 9; x++)
{
for(y = 1;y <= x; y++)
{
System.out.print(y+"*"+x+"="+x*y+"\t");
}
System.out.println();
}
}
}
然後進入cmd命令行,通過cd 進入Demo.java所在的盤符 然後
先通過javac Demo.java編譯
再 通過 java Demo運行即可