
18.09.2011, 18:39
|
 |
I Like it!
|
|
Регистрация: 12.12.2009
Адрес: Россия, г. Новосибирск
Сообщения: 663
Версия Delphi: D6/D7
Репутация: 26643
|
|
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
l = 3;
a: array[1..l*2] of Byte = ($7F, $D9, $91, $AB, $6E, $CB);
var
Form1: TForm1;
implementation
{$R *.dfm}
function CheckSumm(x: array of Byte; lx: Integer): LongWord;
var
b: array of Word;
i: Integer;
begin
Result := 0;
if Odd(lx) then Exit;
SetLength(b, lx div 2);
Move(x[0], b[0], lx);
for i := 1 to (lx div 2) do
Result := Result + swap(b[i-1]);
SetLength(b, 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(IntToHex(CheckSumm(a, l * 2), 8));
end;
end.
__________________
Грамотно поставленный вопрос содержит не менее 50% ответа.
Грамотно поставленная речь вызывает уважение, а у некоторых даже зависть.
|