{с клавиатуры вводится число до тех пор, пока не будет введено 3-х значное, сумма первых двух цифр записывается в a, сумма десятков и единиц - в b. Сравнивается какое из них больше и выводится в порядке возрастания} Uses Crt; var a,c,b:integer; begin ClrScr; repeat writeln('INPUT 3-x znachoe'); readln(b); until (b>=100)and(b<=999); a:=b div 100+(b div 10)mod 10; c:=(b div 10)mod 10+b mod 10; if a<c then writeln(a,c) else writeln(c,a); Readkey; end.
DECLARE FUNCTION f# (x AS DOUBLE) DECLARE FUNCTION Integ# (a AS DOUBLE, b AS DOUBLE, n AS LONG)
'Main program DIM eps AS DOUBLE, n AS LONG, s AS DOUBLE, s1 AS DOUBLE DIM a AS DOUBLE, b AS DOUBLE CLS a = 0: b = 1: eps = .001 n = 100 s = Integ#(a, b, 10#) DO s1 = s s = Integ#(a, b, n) n = n * 2 LOOP UNTIL ABS(s - s1) <= eps PRINT s END
FUNCTION f# (x AS DOUBLE) f# = x ^ 3 * EXP(x ^ 2) END FUNCTION
FUNCTION Integ# (a AS DOUBLE, b AS DOUBLE, n AS LONG) DIM h AS DOUBLE, xb AS DOUBLE, x AS DOUBLE DIM s AS DOUBLE, i AS INTEGER h = (b - a) / n s = 0 xb = a FOR i = 0 TO n - 1 x = xb + i * h s = s + f(x) * h NEXT i Integ# = s END FUNCTION
Результат выполнения программы: .4991509793572241 Погрешность не превышает 0.001 при контрольном значении, равном 0.5
Uses Crt;
var
a,c,b:integer;
begin
ClrScr;
repeat
writeln('INPUT 3-x znachoe');
readln(b);
until (b>=100)and(b<=999);
a:=b div 100+(b div 10)mod 10;
c:=(b div 10)mod 10+b mod 10;
if a<c then
writeln(a,c)
else
writeln(c,a);
Readkey;
end.
DECLARE FUNCTION Integ# (a AS DOUBLE, b AS DOUBLE, n AS LONG)
'Main program
DIM eps AS DOUBLE, n AS LONG, s AS DOUBLE, s1 AS DOUBLE
DIM a AS DOUBLE, b AS DOUBLE
CLS
a = 0: b = 1: eps = .001
n = 100
s = Integ#(a, b, 10#)
DO
s1 = s
s = Integ#(a, b, n)
n = n * 2
LOOP UNTIL ABS(s - s1) <= eps
PRINT s
END
FUNCTION f# (x AS DOUBLE)
f# = x ^ 3 * EXP(x ^ 2)
END FUNCTION
FUNCTION Integ# (a AS DOUBLE, b AS DOUBLE, n AS LONG)
DIM h AS DOUBLE, xb AS DOUBLE, x AS DOUBLE
DIM s AS DOUBLE, i AS INTEGER
h = (b - a) / n
s = 0
xb = a
FOR i = 0 TO n - 1
x = xb + i * h
s = s + f(x) * h
NEXT i
Integ# = s
END FUNCTION
Результат выполнения программы:
.4991509793572241
Погрешность не превышает 0.001 при контрольном значении, равном 0.5