根據妳的想法,我為妳改進了它:
包裝文本;
導入Java . util . scanner;
公共類文本2 {
/**
* @param args
*/
公共靜態void main(String[] args) {
// TODO自動生成的方法存根
掃描儀輸入=新掃描儀(system . in);
System.out.print("行號:");
布爾ischoice = true
int a = 0;
while (ischoice) {
string a 1 = input . next();
嘗試{
a = integer . parse int(a 1);
ischoice = false
}
捕捉(例外e)
{System.out.println("請輸入壹個數字!");}
}
for(int I = a;我& gt0;我- ) {
for(int j = I;j & gt0;j - ) {
system . out . print(" * ");
}
system . out . println(" ");
}
}
}