Autor Beitrag
LonghornUser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Mo 19.06.06 22:01 
Hallo,
ich möchte checken, ob eine Zahl folgende Wete annimmt. (immer 100 plus 100 plus 100, ...). Nun soll diese Reihe bis 10000 gehen. Das wäre mit der untenstehenden Variante doch sehr dumm, oder :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
if (l = 100or (l = 200or (l = 300or (l = 400or (l = 500)
or (l = 600or (l = 700or (l = 800or (l = 900or (l = 1000)
or (l = 1100or (l = 1200or (l = 1300or (l = 1400or (l = 1500)
or (l = 1600or (l = 1700or (l = 1800or (l = 1900or (l = 2000then

Wie kann ich das wenigstens etwas kürzer coden ?

Danke schonmal.

Ciao LHUser
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 19.06.06 22:05 
ausblenden Delphi-Quelltext
1:
if (l >= 100and if (l <= 2000and (l mod 100 = 0then ...					

_________________
Markus Kinzler.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 19.06.06 22:14 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
if Number >= 100 then
  if Number <= 10000 then
   if Number mod 100 = 0 then
    ...
:P


//edit a) zu lahm und b) das gleiche wie mkinzler gepostet -.-
Jetstream
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 222



BeitragVerfasst: Mo 19.06.06 22:34 
Mal ganz allgemein:

Der Befehl a mod b gibt den rest aus, wenn du a durch b teilst.

Eine Zahl a ist genau dann durch 100 teilbar, wenn a mod 100 = 0, d.h. wenn die 100 ohne rest in a reinpasst.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Mi 21.06.06 14:08 
Danke !! :)
if l MOD 100 = 0 then
hat geklappt.