w3schools截圖
//蘇芝霖,2022/10/20,Java迴圈for loop
public class Main {
public static void main(String[] args) {
int i,j; /*宣告整數integer變數i*/
String a="第",b="列: ";
System.out.println("蘇芝霖,2022/10/20,Java迴圈for loop");
for (i = 9 ; i > 0; i--) { /*迴圈,控制*/ System.out.print(a+i+b); /*系統的輸出的列印完換列println*/
for(j = 0; j <= i; j++)
System.out.print(j);
System.out.println('-');
}
}
}
//蘇芝霖,2022/10/20,Java迴圈for loop
public class Main {
public static void main(String[] args) {/*curly捲bracket*/
int i, j; /*宣告整數integer變數i*/
String a="第", b="列: "; /*宣告字串a,b且給初始值*/
System.out.println("劉任昌,2022/10/20,Java迴圈for loop");
for (i = 9 ; i > 0; i--) { /*迴圈,i控制*/
System.out.print(a+i+b); /*系統的輸出的列印完換列println*/
for (j = 0; j <= i ; j++)/*j 控制欄方向*/
System.out.print(j); /*迴圈內僅一指令,可省略{...}*/
System.out.println('.'); /*println=print line*/
}
for (i = 40845; i < 40860; i++){
a = Character.toString(i); /*字元的.方法toString轉成字串*/
b = " 字碼的字元: ";
System.out.println(i + b + a);
}
}
}
優秀!
回覆刪除