Объяснение:
program XandY;
const
rndlim=50;
var
x, y : integer;
begin
x:=random(rndlim);
y:=random(rndlim);
Writeln('x=',x,' y=', y);
Writeln('x+y = ',x+y);
Writeln('x-y = ',x-y);
Writeln('x*y = ',x*y);
Writeln('x^2 + y^2 = ',sqr(x)+sqr(y));
end.
Запуск:
Free Pascal Compiler version 2.6.2-8 [2014/01/22] for x86_64
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling main.pas
Linking a.out
16 lines compiled, 0.2 sec
x=27 y=29
x+y = 56
x-y = -2
x*y = 783
x^2 + y^2 = 1570
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cool{
class main
{
static void Main(string[] args)
{
int u1 = 1, u2 = 2;
int l1 = 1, l2 = 1;
double a = 0, eps = 0.001;
int i = 2;
int U, L;
double A;
U = u2 + u1;
L = l2 + l1;
A = (double)U / L;
while (Math.Abs(A - a) > eps || i < 5)
{
a = A;
i++;
l1 = l2; u1 = u2;
l2 = L; u2 = U;
U = u2 + l2;
L = l2 + l1;
A = (double)U / L;
#if DEBUG
Console.WriteLine("{0} -> {1}|{2}", i, U, L);
#endif
if (i == 5)
Console.WriteLine("Пятый элемент: {0}", A);
if (Math.Abs(A - a) < eps)
Console.WriteLine("Элемент, отличающийся на менее чем {1}: {0}", A, eps);
}
}
}
}