標題:
巢狀迴圈 - 小星星 (一)
[打印本頁]
作者:
陳品肇
時間:
2019-7-2 23:22
標題:
巢狀迴圈 - 小星星 (一)
利用巢狀回圈, 將符號*整齊排列成如下之三角形:
public class Ch19
{
public static void main(String args[])
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5-i; j++)
System.out.print(" ");
for(int k=1; k<=2*i-1; k++)
System.out.print("*");
System.out.println();
}
}
}
複製代碼
作者:
林侑成
時間:
2019-7-3 10:48
import java.util.Scanner;
public class ASDF
{
public static void main(String[] args)
{
for(int i=1;i<=5;i++)
{
for(int s=1;s<=5-i;s++)
{
System.out.print(" ");
}
for(int d=1;d<=2*i-1;d++)
{
System.out.print("*");
}
System.out.println();
}
}
}
複製代碼
作者:
黃恆嘉
時間:
2019-7-3 11:22
本帖最後由 黃恆嘉 於 2019-7-3 11:29 編輯
public class Ch05 {
public static void main(String[] args) {
for (int i = 0; i <= 4; i += 1) {
for (int n = 1; n <= 5 - i; n += 1) {
System.out.print(" ");
}
for (int m = 1; m <= (1 + (i * 2)); m += 1) {
System.out.print("*");
}
System.out.println();
}
}
}
複製代碼
作者:
張閎鈞
時間:
2019-7-3 11:50
package text369;
import java.util.Scanner;
public class text123 {
public static void main(String[] args) {
for(int i=1;i<=5;i++)
{
for(int k=1;k<=(5-i);k++)
{
System.out.print(" ");
}
for(int j=1;j<=(2*i-1);j++)
{
System.out.print("^");
}
System.out.println();
}
}
}
複製代碼
作者:
呂昀宸
時間:
2019-7-3 11:53
package nsez;
import java.util.Scanner;
public class nsez {
public static void main(String[] args) {
Scanner z = new Scanner(System.in);
for (int a = 1; a <= 5; a = a + 1) {
for (int c=1;c<=5-a;c++)
System.out.print(" ");
for (int b = 1; b <= 2 * a - 1; b++) {
System.out.print("*");
}
System.out.println();
}
}
}
複製代碼
作者:
湯東緯
時間:
2019-7-3 11:53
package ch01;
import java.util.Scanner;
public class Ch01 {
public static void main(String[] args) {
for (int i=1 ;i<=5;i++) {
for (int j=1;j<=5-i;j++) {
System.out.println("");
for(int k=1;k<=2*i-1;k++){
System.out.println("*");
}
System.out.println();
}
}
複製代碼
作者:
蔣宗儒
時間:
2019-7-3 11:54
package junior;
public class junior {
public static void main(String args[]) {
for (int i = 1; i <= 5; i += 1) {
for (int m = 1; m <= 5 - i; m += 1)
System.out.print(" ");
for (int n = 1; n <= (2 * i) - 1; n += 1)
System.out.print("*");
System.out.println(" ");
}
}
}
複製代碼
作者:
潘承渙
時間:
2019-7-3 11:59
import java.util.Scanner;
public class Ch05 {
public static void main(String args[]) {
for (int a = 1; a <= 5; a = a + 1) {
for (int b = 1; b <= 5 - a; b++) {
System.out.print(" ");
}
for (int c = 1; c <= 2 * a - 1; c++) {
System.out.print("*");
}
System.out.println();
}
}
}
複製代碼
作者:
黃安立
時間:
2019-7-3 12:01
public class Ch05 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5 - i; j++) {
System.out.print(" ");
}
for (int k = 1; k <= 2 * i - 1; k++) {
System.out.print("$");
}
System.out.println();
}
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2