这个 Pascal 语法是什么意思
这是这段代码:
for i:= 1 to n
do Write(a[i]:6:2);
Writeln;
For 循环从数组输出数据。
请帮忙 - Write()
中的 :6:2
是什么意思?
提前致谢!
Here's this code:
for i:= 1 to n
do Write(a[i]:6:2);
Writeln;
For loop outputs data from array..
Please, help - What does :6:2
in Write()
mean?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是输出格式。这意味着使用 6 位数字进行输出,并保留 2 位小数
It's output formatting. This means use 6 digits for output with 2 decimal positions
如果 a 中有数字/小数,这将格式化您的输出。如果我没记错的话,在你的例子中,2表示0以下的最大小数位数,6表示0以上的数字打印的最大位数
。HTH
多米尼克
this will format your output in case you have a number/decimal in a. If i remember correctly, in your case, the 2 means the max number of decimal places below 0 and the 6 the maximum digits printed for numbers above 0.
HTH
Dominik
规范 x:n:m 表示 n 和 m 小数位的字段宽度。它将被格式化为真实的。如果 x=17.8,则 x:6:2 结果为“17.80”。请注意,它是一个前导空格,并且是右对齐的。如果 m 为 0,则没有小数点,也没有尾随数字。如果您使用 x:n 作为格式,您将获得字段宽度为 n 的科学记数法。
此外,n 和 m 可以是整数变量,因此可以在执行期间更改字段宽度和小数点。
The spec x:n:m means a field width of n and m decimal places. It will be formatted as a real. If x=17.8 then x:6:2 comes out as " 17.80". Note that it is one leading space and that it is right justified. If m is 0 then no decimal point and no trailing digits. If you have x:n as the format you get scientific notation in a field width of n.
Also, n and m can be integer variables, so the field widths and decimal points can be changed during execution.