Thema: Byte to int

Einzelnen Beitrag anzeigen

Kuehter

Registriert seit: 14. Okt 2014
59 Beiträge
 
Delphi 7 Professional
 
#15

AW: Byte to int

  Alt 17. Okt 2014, 10:30
Ja ich nehm Arbeitslaptop Wochenende jetzt auch mit nach hause, um das zu testen sonst denkt man da die ganze zeit dran.

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ImgList, jpeg, Types, Contnrs;

type
  Tintegerarray = array of integer;
  Tpicarray = array of TPicture;
  Tstringarray = array of String;

  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Button1: TButton;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    Image6: TImage;
    Image7: TImage;
    Image8: TImage;
    Image9: TImage;
    Image10: TImage;
    Image11: TImage;
    Image12: TImage;
    Image13: TImage;
    Image14: TImage;
    Image15: TImage;
    Image16: TImage;
    Image17: TImage;
    Image18: TImage;
    Image19: TImage;
    Image20: TImage;
    Image21: TImage;
    Image22: TImage;
    Image23: TImage;
    Image24: TImage;
    Image25: TImage;
    Image26: TImage;
    Image27: TImage;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);



  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation
{$R *.dfm}



function numberdissect(numbers: Cardinal): TByteDynArray;

var
    safer: integer;
    i: integer;

begin

    safer := 0;
    SetLength(Result,2);
    while numbers <> 0 do
    begin
      Result[safer] := numbers mod 10;
      numbers := numbers div 10;
      inc(safer);
    end;

    If Result[2] = not(null) then
    begin
        i := Result[0];
        Result[0] := Result[2];
        Result[2] := i;
    end
    else
    begin
        i := Result[1];
        Result[1] := Result[0];
        Result[0] := i;
    end;


end;





function Symbolspeicher: Tstringarray;
var
  counter: integer;
  swap : String;
  merker1, merker2: integer;

begin

    SetLength(Result,9);

    for counter := low(Result) to high(Result) do
    begin
      Result[counter] := 'Symbolik_' + intToStr(counter) + '.jpg';
    end;

    for counter := low(Result) to high(Result) do
    begin

      merker1 := trunc(random(high(Result)))+Low(result);
      merker2 := trunc(random(high(Result)))+Low(result);

      swap := Result[merker1];
      Result[merker1] := Result[merker2];
      Result[merker2] := swap;

    end;

end;





function picload: Tpicarray;

var counter: integer;
    picPath: Tstringarray;


begin
  picPath := Symbolspeicher;
  SetLength(result,10);

  for counter := Low(result) to high(Result) do
  begin
    Result[counter] := TPicture.Create;
    Result[counter].LoadFromFile(picPath[counter]);
  end;

end;






function bedingung: Tintegerarray;
var
  Generierer: array[0..3] of integer;
  max, max2: integer;

begin

    repeat

      Generierer[0] := trunc(random(899))+100;
      max := 999 - Generierer[0];
      Generierer[1] := trunc(random(max))+10;
      Generierer[2] := trunc(random(max))+10;
      max := 999 - Generierer[1];
      max2 := 999 - Generierer[2];

      if max > max2 then
        Generierer[3] := trunc(random(max2))+10
      else
        Generierer[3] := trunc(random(max))+10;


      SetLength(result,9);
      result[0] := Generierer[0];
      result[1] := Generierer[1];
      result[2] := Generierer[2];
      result[3] := Generierer[3];
      result[4] := Generierer[0] + Generierer[1]; //A2 + A1 = C1
      result[5] := Generierer[2] + Generierer[0]; //B1 + A1 = C2
      result[6] := Generierer[1] + Generierer[3]; //A2 + B2 = D1
      result[7] := Generierer[2] + Generierer[3]; //B1 + B2 = D2
      result[8] := Result[5]+Result[6]; //engergebnis


   until(result[8] <= 999);

   if (Result[8] = Result[4] + Result[7]) then
        ShowMessage('Die Zahlen Stimmen ')
   else
        ShowMessage('Die Zahlen stimmen nicht');

end;






procedure TForm1.Button1Click(Sender: TObject);
type
    Allrounder = TImage;

var
    rec : TIntegerarray;
    pics : Tpicarray;
    saferend: TByteDynArray;
    firstIcon: Tstringarray;
    counter, oneup: integer;
    middlesafer : array[0..26] of Smallint;
    nein : array[0..26] of String;


begin

    oneup := 0;
   SetLength(saferend,3);
   rec := bedingung;
   firstIcon := Symbolspeicher;
   Pics := picload;


   Edit1.Text := InttoStr(rec[0]);
   Edit2.Text := InttoStr(rec[1]);
   Edit3.Text := InttoStr(rec[4]);

   Edit4.Text := InttoStr(rec[2]);
   Edit5.Text := InttoStr(rec[3]);
   Edit6.Text := InttoStr(rec[7]);

   Edit7.Text := InttoStr(rec[5]);
   Edit8.Text := InttoStr(rec[6]);
   Edit9.Text := InttoStr(rec[8]);

   repeat
      for counter := 0 to 3 do
      begin
          middlesafer[counter] := (numberdissect(rec[oneup])); (*[Fehler] Unit1.pas(274): Inkompatible Typen: 'Smallint' und 'TByteDynArray'  *)
      end;
      inc(oneup);
   until oneup = 9;


   for counter := low(middlesafer) to high(middlesafer) do (* WEnn ich aus dem smallint ein ByteDynArray mache *)
   begin
      case middlesafer[counter] of
      0: picload[0];

      else
      end;

   end;

end;





procedure TForm1.FormCreate(Sender: TObject);
begin
       Randomize;
end;



end.
nicht nur Delphi sondern auch Java und C# formen die Welt

Geändert von Kuehter (17. Okt 2014 um 10:37 Uhr)
  Mit Zitat antworten Zitat