Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 1/Programming Assignment/zh CN

한국어 · Deutsch · English · Français · Български · Русский · 中文(中国) · 日本語

1H - 编程作业 (原作者: Tao Yue, 状态: 未更改)

你学会了如何定义变量和改变它们的值。现在,开始做你的第一个作业吧?

不过,有个小问题:你还不知道如何将数据显示在屏幕上。

所以,在开始之前,下面的代码将用来显示数据,并在以后的作业中使用到:

pascal
writeln (????????????);

参数列表是由字符串或以逗号分隔的变量名来组成,如:

pascal
writeln ('Sum = ', sum);

编程作业:

在45、68、2、34,这5个整数中,求出它们的平均值、总和。 (求和运算,结果类型应该为整数型;求平均值是实数型。)

使用常量存储该程序处理整数的数目,即定义一个常量,值为5。

然后显示它,显示应该是这个样子:

text
Number of integers = 5
Number1 = 45
Number2 = 7
Number3 = 68
Number4 = 2
Number5 = 34
Sum = 156
Average = 3.1200000000E+01

正如你看到的,实数默认以科学记数法方式显示。

第2章将解释如何格式化为小数。

解决方法?下一页会看到。

上一页 目录 下一页

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Programming Assignment/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 .

Talk about this page

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