这个 Pascal 语法是什么意思

发布于 2024-11-16 11:52:33 字数 187 浏览 2 评论 0原文

这是这段代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小伙你站住 2024-11-23 11:52:33

这是输出格式。这意味着使用 6 位数字进行输出,并保留 2 位小数

It's output formatting. This means use 6 digits for output with 2 decimal positions

若有似无的小暗淡 2024-11-23 11:52:33

如果 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

拍不死你 2024-11-23 11:52:33

规范 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文