You can use a *
in place of the precision. Then you can pass it an an int
argument:
printf("%.*f
", i, N);
This doesn't print any trailing zeros, but you can add that as follows:
for (i=0;i<X;i++) {
printf("%#.*f", i, N);
if (i<X) printf("%0*d", X-i, 0);
printf("
");
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…