编码的奥秘二
1,算术平方
begin
real a, b;
print ('Enter a number: ');
read (a);
if a< 0 then
print ('Sorry, the number was negative.');
else
begin
b = sqrt (a);
print ('The square root of', a, 'is', b);
end
end
2, 3-99间奇数的立方值
begin
real a, b;
for a :=3 step 2 until 99 do
begin
b :=a× a× a;
print ('The cube of', a,' is', b);
end
end
3, 假设程序用计算3、5、7和9的立方
begin
real a, b;
for a := 3, 5, 7, 9do
begin
b := a× a× a;
print (' The cube of ', a, 'is', b);
end
end