Autor Beitrag
Paulchengb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 39



BeitragVerfasst: Mo 09.04.07 21:22 
Hallo,

wie kann man mit Delphi zählen, wie oft zB. die Ziffer 1 in 39183717382711 vorkommt?

Und wie kann ich die Zahl 39183717382711 in die einzelnen Stellen zerlegen, so dass ich auslesen kann, welche Ziffer auf der 4. Stelle steht?

Erstmal in nen string verwandeln, aber dann?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 09.04.07 22:03 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Button1Click(Sender: TObject);
var
 MeineZahl:String;
 Anzahl,i:Integer;
begin
  Anzahl:=0;
  MeineZahl:='39183717382711';
  for i := 1 to Length(MeineZahl) do
   begin
     if (MeineZahl[i] = '8')then
       Inc(Anzahl);
       Label1.Caption:=Inttostr(Anzahl);
       Label2.Caption:=MeineZahl[4];
   end;
end;

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)