Autor Beitrag
The-FoX
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 203

Win XP
D6 Pers
BeitragVerfasst: Do 21.08.03 02:59 
Hi.

Wie kann ich z.B. automatisch die Zahlen 1 - 20000 erzeugen und denen jeweils a für 1, b für 2 usw. zuweisen? Ich habe das Gefühl das es irgendwas mit arry zu tun hat, komm aber nicht drauf.

thx im vorraus!
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Do 21.08.03 07:52 
Wie wäre folgender Vorschlag:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  i: Integer;
  Zahlen: array [0..19999of Integer;
begin
  for i := 0 to 19999 do
    begin
      Zahlen[i] := i+1;
    end;
end;

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
The-FoX Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 203

Win XP
D6 Pers
BeitragVerfasst: Mo 25.08.03 04:53 
ok, thx!
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 25.08.03 05:14 
Hi,
derDoc hat folgendes geschrieben:
Wie wäre folgender Vorschlag:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  i: Integer;
  Zahlen: array [0..19999of Integer;
begin
  for i := 0 to 19999 do
    begin
      Zahlen[i] := i+1;
    end;
end;

Schaut verwirrt... was soll das bringen ausser einem ungeheuren, total überflüssigem Speicherverbrauch??? ;)

Au'revoir,
Aya~

@FoX: Aber ich verstehe deine frage nich so richtig... erklär mal genauer was du erreichen willst.

_________________
Aya
I aim for my endless dreams and I know they will come true!
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Mo 25.08.03 08:16 
@derDoc: Damit ist das Problem aber nicht gelöst.

@TheFoX: Was ist denn, wenn die Zahl größer als die Zahl wird, der ein "z" zugeordnet wurde? Soll dann wieder bei a angefangen werden?

Schau dir mal folgenden Code an:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  j: Byte;
begin
  j := 64;  //der "Bytewert" von A ist 65
  for i := 0 to 19999 do
  begin
    Inc(j);
    ListBox1.Items.Add(IntToStr(i + 1) + ' : ' + Chr(j));
    if j = 90 then
      j := 64;
  end;
end;


Der schreibt dir Zahlen von 1 bis 20000 mit dem "dazugehörigen" Buchstaben in eine Listbox. Daraus jetzt einen Code zu machen, der das alles in ein Array schreibt ist nicht schwer. Wenn du aber Probleme bekommst, frag. :)

//EDIT

Ok, hatte gerade Lust, mal den Code zu tippen. Habe hier aber eine etwas unnötige Konstruktion gemacht. Man könnte auf den Typ "arrayitem" verzichten, da man anhand der Position im Array die Zahl herausbekommt. Nun gut, hier aber mal der Code: (Habe ihn nicht auf korrekte "Füllung des Arrays" geprüft)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure TForm1.Button1Click(Sender: TObject);

  type
    arrayitem = record
      zahl: Integer;
      buchstabe: Char;
    end;

var
  i: Integer;
  j: Byte;
  zahlundbuchstabe: array [0..19999of arrayitem;
begin
  j := 64;  //der "Bytewert" von A ist 65
  for i := 0 to 19999 do
  begin
    Inc(j);
    zahlundbuchstabe[i].zahl := i + 1;
    zahlundbuchstabe[i].buchstabe := Chr(j);
    if j = 90 then
      j := 64;
  end;
end;


//Edit2
Habe bei der Prüfung des Codes gemerkt, dass ein Problem entstanden ist. Daher habe ich den Code, den ich oben gepostet habe korrigiert. Diser sollte daher funktionieren.

_________________
Viele Grüße
Jakob
Taurin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 34

Win XP
D6 Personal
BeitragVerfasst: Mo 25.08.03 17:11 
Ähhh..... Was haltet ihr davon????

ausblenden Delphi-Quelltext
1:
2:
3:
4:
function MakeTheChar(a :Cardinal) :char;
  begin
  result := chr(((a-1mod 26) + ord('A'));
  end;
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mo 25.08.03 19:06 
Wenn ich die Frage am Anfang richtig verstanden habe will er a = 1, b = 2, ...
Frage an den Autor der ersten Frage:
Wie soll es nach z weitergehen? Wieder a oder aa?

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.