Страница 1 из 1

ЗаДача НА МАССИв для РГР

Добавлено: 09 июн 2005, 01:48
Wudro
24.Даны последовательность x1<x2<..xn вещественных чисел и вещественное число y. Напишите программу для вычисления такого k, что xk<y<xk+1

Здесь x1,x2,xn,xk,xk+1 , всё что после x это нижние индексы
(на массив)

Добавлено: 10 июн 2005, 12:34
VirusXP
в чем проблема то???!!!)))P
-------------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private { Private declarations }
public { Public declarations }
end;

var Form1: TForm1;

implementation

const ArrIn: array[1..7] of real = (1, 4, 7, 9, 10, 4, 6);
CheckReal = 5;

{$R *.dfm}

function check(AInd: integer): boolean;
begin
result := (CheckReal > ArrIn[AInd]) and (CheckReal < ArrIn[AInd + 1]);
end;

procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
for i := Low(ArrIn) to High(ArrIn)-1 do
if check(i) then
self.Caption := self.Caption + ' ' + FloatToStr(i); // íàïðèìåð
end;

end.