![](/img/trans.png)
[英]System.out in DataOutputStream is not printing on the console
[英]Simple System.out printing
好的,我有這個問題,我該如何編碼,但之間沒有空行
X
y
xxy
xxyy
xxxyy
xxxyyy
到目前為止,這是我的代碼
public static void main(String[] args) {
System.out.print("x");
for(int i = 0;i<6;i++){
for(int j = 0;j<i;j++){
System.out.print("x");
}
System.out.println();
}
}
模式如下:
1x,0y
1x,1y
2x,1y
2x,2y ...
因此,您的循環應如下所示:
int xCount = 0;
int yCount = 0;
int total = 3;
do {
if (xCount == yCount) xCount++;
else yCount++;
for (int x = 0; x < xCount; x++) System.out.print("x");
for (int y = 0; y < yCount; y++) System.out.print("y");
System.out.println();
} while (yCount < total);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.