使用Java语言编程输出星号

*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *

public class PrintStart {

public static void main(String[] args) {

int num = 10;
for(int i = 1; i <= num; ++i){
int space = num - i;
for(int j = 0; j < space; ++j)
System.out.print(" ");
for(int x = 0; x < i; ++x)
System.out.print("*");
System.out.println();
}
}
}

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答