Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 2/Formatting output/zh CN

Sent here from Formatting output/zh CN.

Deutsch · English · Français · Български · 中文(中国) · 日本語

2C - 格式化输出 (原作者: Tao Yue, 状态: 未更改)

格式化输出很易用,如下:

pascal
??? : ????????????

字段长度指,显示的数据右对齐后占用的宽度。如果宽度不足以显示全部数据,那么指定的字段长度将被忽略(看下面示例)。

如下语句:

pascal
write ('Hi':10, 5:4, 5673:2);

输出将是(Hi前面有8个空格,后面有3个。)

text
        Hi   55673

你可以设置字段长度,以科学计数法形式显示实数。也可以指定小数位数:

pascal
??? : ???????????? : ?????????

字段长度是总占用宽度,包括小数部分。如果宽度无法显示全部数值,整数部分将会被显示出来;如果小数位超出设定的位数,将被四舍五入。

pascal
write (573549.56792:20:2);

会是什么样子(有11个空格在前面)?

text
           573549.57
上一页 目录 下一页

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 2/Formatting output/zh CN", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 3, last changed by WikiArchive .

Edited on wiki.freepascal.org by 5 people, 2013–2022

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
WangyouworldCreated page
Swen (minor)
Wangyouworld
FTurtle
TrevFixed syntax highlighting; deleted category included in page template (minor)
Kai BurghardtKai Burghardt moved page Formatting output/zh CN to Basic Pascal Tutorial/Chapter 2/Formatting output/zh CN: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Speci... (minor)
Kai Burghardtbypass redirects [cf. discussion]
Kai Burghardtbypass [previously missed] redirect [cf. discussion]
Kai Burghardtbypass language bar/categorization template redirect [cf. discussion] (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.