0
import java.util.Scanner;
public class Project6
{
public static void main(String[] args)
{
int height =0;
int width =0;
boolean run = true;
Scanner scanner = new Scanner(System.in);
int rows = 0;
while(run)
{
System.out.println("Please Specify The Demensions of Your Arrow:");
System.out.print("\tHeight: ");
if(!(scanner.hasNextInt()))
{
System.out.println("Please Enter an Integer.");
}
else
{
height = scanner.nextInt();
if(!(height > 0))
{
if(height == -1)
{
break;
}
else
{
System.out.println("Please Enter A Positive Integer");
}
}
else
{
System.out.print("\tWidth: ");
if(!(scanner.hasNextInt()))
{
System.out.println("Please Enter An Integer");
}
else
{
width = scanner.nextInt();
if(!(width > 0))
{
if(width == -1)
{
break;
}
else
{
System.out.println("Please Enter A Positive Integer");
}
}
}
}
if(width % 2 == 0)
{
System.out.println("Width is an Even Number");
}
else
{
System.out.println("Width is odd");
for(int numRow = width; numRow >= 1; numRow -=2)
{
System.out.println(numRow);
rows++;
}
System.out.println("Number of Rows: " + rows);
}
/*if(height % 2 == 0)
{
System.out.println("height is an Even Number");
}
else
{
System.out.println("height is odd");
for(int numCol = height; numCol >= 1; numCol -=2)
{
System.out.println(numCol);
}
}*/
}
}
}
}
我在評論中放了一部分,因爲我不確定是否要保留它。這是盡我所能。我不知道該從哪裏出發。基本上就是我想要做的是,比如你輸入身高:10和寬:9,它看起來像這樣:我需要幫助製作一個程序,讓您指定控制檯中的箭頭的尺寸
*
***
*****
*******
*********
***
***
***
***
***
可能重複 - 格式化打印輸出](http://stackoverflow.com/questions/8935254/pascals-triangle-2d-array-formatting-printed-output) – weston 2014-09-11 13:05:29
我已添加一個重複的問題鏈接。你想要達到的是更容易的,而不是你剛纔的數字'*' – weston 2014-09-11 13:06:38
啊好吧,現在我可以看到它,但它仍然非常相似。 – weston 2014-09-11 13:07:38