Autor Beitrag
master5
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Fr 21.01.05 17:37 
tja der titel sagt eigentlich schon alles ich will ein programm sreiben aber ich weis nicht wie ich ein random mit buchstaben oder wörtern mache
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 21.01.05 17:43 
ausblenden Delphi-Quelltext
1:
C := Chr(65+Random(26));					

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Fr 21.01.05 19:04 
Und ein "Wort" kannst du so machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
function RandomString(Length: integer);
var i:integer;
begin
 SetLength(Result,0);
 // Die 65 steht für das große A
 // die erste 26 schließt alle Großbuchstaben ein
 // die zweite 26 schließt alle Kleinbuchstaben ein
 for i:=1 to Length do Result:=Result+Chr(65+Random(26 + 26));
end;

Wie immer ungetestet!

Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 22.01.05 01:15 
Zeile 8 ist falsch ...

Müsste Chr(65 + Random(26) + Random(2) shl 5) heißen

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Sa 22.01.05 09:49 
Sry, da blick ich jetzt nicht durch - warum ist Zeile 8 falsch?

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
ScorpionKing
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1150

Win XP

BeitragVerfasst: Sa 22.01.05 10:00 
weils dann ein random aus 52 macht.
und dann können manchmal falsche buchstaben bzw. gar keine sondern nur komische ziechen rauskommen!

_________________
Aus dem Urlaub zurück!
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Sa 22.01.05 10:10 
Ah, stimmt! Ich war der festen Überzeugung, dass nach dem großen Z ein kleines a kommt - so kann man sich irren :lol:

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
ScorpionKing
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1150

Win XP

BeitragVerfasst: Sa 22.01.05 10:13 
na ja, ich weiß auch warum die lieben leute, die computer erfunden haben, dass so gemacht haben:

das wäre zu einfach. jeder programmierer mag es ja schwer! :wink:

ne, kleiner scherz!

_________________
Aus dem Urlaub zurück!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 22.01.05 14:52 
Nö, ist so eigentlich viel einfacher:

In HEX betrachten gilt:

ausblenden Quelltext
1:
2:
3:
A --> 41    a --> 61
B --> 42    b --> 62
...


Bei den Umlauten und den nicht-ASCII_Zeichen stimm ich Dir aber zu... Das wäre zu einfach gewesen ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
master5 Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: So 23.01.05 09:46 
vielen dank an alle ihr habt mir sehr geholfen 8)