내가 마음에 내 삼각형 번호 생성기, 곰 이상한 오류를 데 내가 프로그래밍에 아주 새로운 오전. 프로그램의 특정 지점 번호 결함 밖으로 일부가 마이너스 숫자에서 는 (이 숫자는 단지이없는 것을 주목할 필요가있다! - 그들 앞에서 실제로 밖으로 glitched된다)자바 삼각형 번호 계산기
import java.util.Scanner;
public class TriangularNumbers {
@SuppressWarnings("resource")
public static void main(String args[]) {
int tnumber = 1;
int amount = 2;
System.out.println("Welcome to the triangular numbers calculator!");
System.out.println("Type in the amount of triangular numbers to be generated!");
Scanner reps = new Scanner(System.in);
int repeats = reps.nextInt();
int i = 0;
while (i < repeats) {
i = i + 1;
System.out.println(i + ". " + tnumber);
tnumber = tnumber + amount;
amount = (amount + 1);
}
}
}
출력을 추가 할 수 있습니까? – Gaur93
어떤 문제가 있습니까? –
전체 비트 또는 홀수 비트에서의 출력? –