import java.util.Scanner;
public class DrawTriangle
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter a height");
while (!scan.hasNextInt()) // while non-integers are present
{
scan.next();
System.out.println ("Bad input. Enter an integer.");
}
int input = scan.nextInt();
for (int x = 1; x <= input; x++)
{
for (int y = 0; y < input; y++)
{
System.out.print(" ");
for (int z = 1; z < y; z++)
{
System.out.print("x");
}
System.out.println();
}
}
}
나는 사용자가 지정한 높이에 관한 X 년대의 삼각형을해야한다. 전혀 작동하지 못하게되면 어떤 도움을받을 수 있습니다. 감사합니다. 당신은 3 개 단계 개까지 중첩 루프가 필요하지 않습니다
x
xxx
xxxxx
무엇이 문제입니까? –
오, 안돼. 숙제 시즌 이잖아! 나는 중복 된 것을 찾으려고 귀찮아하고 싶지도 않다. – ppeterka
@ppeterka 그것은 항상 ** 삼각형 질문에 대한 계절입니다. 그들은 실제로 그들 모두를 해결하는 태그 위키의 스 니펫과 함께 자신의 태그를 가질 자격이 있습니다. –