-2
我必須解決的問題是我必須從右至左打印*。如果我給5,然後第一個*下一行**等*****必須打印,對齊必須從右到左。我想在Java中從右至左打印*請提供輸入
import java.util.Formatter;
import java.util.Scanner;
public class Problemfour {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
int t1 = 1;
String str = "*";
while (t1 <= t) {
for (int i = 1; i <= t1; i++) {
System.out.print(str);
}
System.out.println("");
t1 += 1;
}
}
}
這看起來像從課件的分配。做你的功課;-) – greut