Autor Beitrag
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 02.09.08 20:28 
Hallo,

ich weiß, ist ne ziemlich simple Frage, aber ich habe grade keinen Plan...

Wie kann ich überprüfen ob ein bestimmter Wert innerhalb eines Arrays vorhanden ist?

Danke schonmal,
Wolle

_________________
1405006117752879898543142606244511569936384000000000.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 02.09.08 20:31 
Moin!

user profile iconWolle92 hat folgendes geschrieben:
Wie kann ich überprüfen ob ein bestimmter Wert innerhalb eines Arrays vorhanden ist?
Die Elemente durchlaufen und abbrechen, wenn du es gefunden hast. ;)

Oder soll es effizient sein? Dafür sind allerdings evtl. ein paar Voraussetzungen nötig. :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 02.09.08 20:32 
Effizient sollte es sein, ja...

Voraussetzungen in wiefern??

_________________
1405006117752879898543142606244511569936384000000000.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Di 02.09.08 20:34 
Hi,

[[[[Also das hättest du dir nun auch selber überlegen können, du willst doch bloß Code abfischen und nicht selbst nachdenken :roll: ]]]]

Oh, hi Wolle. Gut, wenn man vorher den Threadsteller ansieht :lol:

Naja entweder du nimmst ein Set(bis max. 256 Bestandteile) oder so: for Array do if Wert then blabla break;

PS: Merkt man, wie viel Mühe ich mir mit meinem Pseudocode gemacht habe? :nut:

E: Gausi meint eventuell, das Array vorsortiert im Speicher zu haben, etc. für solche Sachen müsste man aber mehr über die Natur der Sache wissen.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)


Zuletzt bearbeitet von Hidden am Di 02.09.08 20:39, insgesamt 1-mal bearbeitet
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 02.09.08 20:37 
Dann schreib ich mir da extra noch ne Prozedur für, weil das nämlich relativ kompakt sein soll, weils doch nen Paarmal ausgeführt wird... dachte es gibt vielleicht schon was fertiges in Pascal dafür...


btw: Kann mir wer meine Deutsch-Hausaufgaben machen?? :roll: :roll:

Öhm... das ist nicht Gausi sondern Narses...

_________________
1405006117752879898543142606244511569936384000000000.


Zuletzt bearbeitet von Wolle92 am Di 02.09.08 20:39, insgesamt 1-mal bearbeitet
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Di 02.09.08 20:38 
user profile iconWolle92 hat folgendes geschrieben:
btw: Kann mir wer meine Deutsch-Hausaufgaben machen?? :roll: :roll:

Sicher. Gibt's 'n Programm für. Suche in der Entwickler-Ecke BRAIN.EXE

Ups, Sry Narses :angel: . [RewriteConstant('Mod', 'Gausi, Narses');]

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 02.09.08 20:50 
Das geht schon wieder nicht!!! Ich krieg die Krise! (oder Kriese?)
Was is denn nu schon wieder falsch:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
function TForm1.IsIntInMDArray(AValue: Integer; PArray: Pointer): Boolean;
var IntArray: Array of Integer;
    IntValue, Count, i, j: Integer;
begin
  result := false;
  Count := Length(^PArray); //<-- Da gibts den Fehler ") erwartet aber ARRAY gefunden"
  SetLength(IntArray, Count);
  IntArray := Copy(^PArray,1,count);
  IntValue := AValue;
  for i := 1 to Count do
  begin
    for j := 1 to Count do
      begin
        if IntValue = IntArray[i][j] then result := true;
      end;
  end;
end;

_________________
1405006117752879898543142606244511569936384000000000.
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Di 02.09.08 21:18 
Das Hütchen ^ muss sich hinter dem Zeiger befinden zum dereferenzieren. Allerdings kann man Pointer eh nicht dereferenzieren - man muss sie erst in einen Typisierten Zeiger umwandeln. Sei PArr ein type PArr = ^TArray: dann musst du length(PArr(parray)^) schreiben.

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)