1
我使用Eclipse的c/C++我试过代码制作pascal's triangle,当我运行它不打印“输入行数”:直到我输入数字后,即使printf谈到scanf函数之前没有提示一个整数
int main(void) {
int rows, coef = 1, space, i, j;
printf("Enter number of rows: ");
scanf("%d", &rows);
printf("\n"); //i added this
for (i = 0; i < rows; i++) {
for (space = 1; space <= rows - i; space++)
printf(" ");
for (j = 0; j <= i; j++) {
if (j == 0 || i == 0)
coef = 1;
else
coef = coef * (i - j + 1)/j;
printf("%4d", coef);
}
printf("\n");
}
return 0;
}
我的问题是,是否有什么毛病我的Eclipse C/C++,因为我从来没有对Eclipse进行Java这个问题时,我问这样的输入。另外我如何解决这个问题。
所以在java中它会自动做什么fflush(标准输出)不会,因为我从未有过这个问题。 –
'System.out.print()'不像'printf'那样缓冲。 –