Написать программу, которая в зависимости от заданного выводит на экран в порядке убывания значения выражений: sin(x), cos(x)/x , ln(x)  — Pascal(Паскаль)

program ac;

uses crt;

Var
  x: integer;
  n, c, b: real;

begin
  clrscr;
  writeln('Введите x');
  readln(x);
  If x < 0 then
  begin
    writeln('Такой результат логарифм не примет');
  end;
  If x = 0 then
  begin
    writeln('На ноль делить нельзя!!!!');
  end
  else
  begin
    n := sin(x);
    c := cos(x) / x;
    b := ln(x);
    writeln(n, ' ', c, ' ', b);
    If (n > c) and (c > b) then
    begin
      writeln(n, ' ', c, ' ', b);
    end;
    If (c > n) and (n > b) then
    begin
      writeln(c, ' ', n, ' ', b);
    end;
    If (b > c) and (c > n) then
    begin
      writeln(b, ' ', c, ' ', n);
    end;
    If (b > n) and (n > c) then
    begin
      writeln(b, ' ', n, ' ', c);
    end;
    If (c > b) and (b > n) then
    begin
      writeln(c, ' ', b, ' ', n);
    end;
    If (n > b) and (b > c) then
    begin
      writeln(n, ' ', b, ' ', c);
    end;
  end;
  readln;

end.

Следующий вариант

Uses
  CRT;

var
  c, c1, c2, x: real;
  t, t1: boolean;

procedure sort(Var k, l: real);
var
  buf: real;
begin
  if k > l then
  begin
    buf := l;
    l := k;
    k := buf;
  end;
end;

begin
  clrscr;
  write('X: ');
  readln(x);
  c := sin(x);
  t := false;
  t1 := false;
  if x <> 0 then
  begin
    c1 := cos(x) / x;
    t := true;
  end
  else
    writeln('с1- деление на 0.Не сортируем');
  if x > 0 then
  begin
    c2 := ln(x);
    t1 := true;
  end
  else
    writeln('с2 не определено!!! Не сортируем.');
  write(c, ' ', c1, ' ', c2);
  writeln;
  if t and t1 then
  begin
    sort(c1, c);
    sort(c2, c);
    sort(c2, c1);
    write(c, ' ', c1, ' ', c2);
  end
  else if t and not(t1) then
  begin
    sort(c1, c);
    write(c, ' ', c1);
  end
  else if not(t) and t1 then
  begin
    sort(c2, c);
    write(c, ' ', c2);
  end
  else
    writeln(c);
  readln

end.

Leave a Comment

16 − = 6