亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

這個怎么輸出

怎么寫出那個星號呈1,3,5,7的形式輸出出來呢

正在回答

3 回答

//輸出菱形
public class Test9 {
?? ?public static void main(String[] args) {
?? ??? ?for(int a=1;a<10;a++){
?? ??? ??? ?for(int j=0;j<9-a;j++){
?? ??? ??? ??? ?System.out.print(" ");
?? ??? ??? ?}
?? ??? ??? ?for(int i=0;i<2*a-1;i++){
?? ??? ??? ??? ?System.out.print("*");
?? ??? ??? ?}
?? ??? ??? ?System.out.println();
?? ??? ?}
?? ??? ?for(int a=1;a<9;a++){
?? ??? ??? ?for(int i=0;i<a;i++){
?? ??? ??? ??? ?System.out.print(" ");
?? ??? ??? ?}
?? ??? ??? ?for(int j=0;j<=2*8-2*a;j++){
?? ??? ??? ??? ?System.out.print("*");
?? ??? ??? ?}
?? ??? ??? ?System.out.println();
?? ??? ?}
?? ??? ?for(int a=6;a<13;a++){
?? ??? ??? ?for(int j=0;j<12-a;j++){
?? ??? ??? ??? ?System.out.print(" ");
?? ??? ??? ?}
?? ??? ??? ?for(int i=0;i<2*a-1;i++){
?? ??? ??? ??? ?System.out.print("*");
?? ??? ??? ?}
?? ??? ??? ?System.out.println();
?? ??? ?}
?? ?}

}

1 回復 有任何疑惑可以回復我~

//倒三角形
public class Test6 {
?? ?public static void main(String[] args) {
?? ??? ?for(int i=1;i<9;i++){
?? ??? ??? ?for(int j=0;j<i-1;j++){
?? ??? ??? ??? ?System.out.print(" ");
?? ??? ??? ?}
?? ??? ??? ?for(int k=0;k<(17-2*i);k++){
?? ??? ??? ??? ?System.out.print("*");
?? ??? ??? ?}
?? ??? ??? ?System.out.println();
?? ??? ?}

?? ?}
}

1 回復 有任何疑惑可以回復我~


http://img1.sycdn.imooc.com//5b2dda860001304307201280.jpg
public class HelloWorld {
public static void main(String[] args) {
System.out.println("打印直角三角形");
for (int i = 1;i<=4;i++) {
for (int s=4-i;s>0;s--) {System.out.print(" ");}
for (int j = 1;j<=i*2-1;j++) {
System.out.print("*");
}
System.out.println();
}
}
}

2 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

這個怎么輸出

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號