Как сгенерировать числа ?

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by FryTvin, 13 Feb 2013.

  1. FryTvin

    FryTvin New Member

    Joined:
    10 Nov 2012
    Messages:
    15
    Likes Received:
    2
    Reputations:
    6
    Как сгенерировать числа от 1 до 9999999 в Delphi ?
    Надо, чтобы выдавало по одному значению на угад из этих чисел .
     
  2. Virous

    Virous New Member

    Joined:
    31 Jan 2013
    Messages:
    17
    Likes Received:
    0
    Reputations:
    0
    Зачем на Delphi то? Можно и так: 538 :)

    По сабжу: your_var:=random(99999999);
     
  3. FryTvin

    FryTvin New Member

    Joined:
    10 Nov 2012
    Messages:
    15
    Likes Received:
    2
    Reputations:
    6
    А если от 100 до 10000 ?
     
  4. Prosta4ok

    Prosta4ok New Member

    Joined:
    25 Oct 2012
    Messages:
    61
    Likes Received:
    0
    Reputations:
    0
    а если прочитать про random?
     
  5. Virous

    Virous New Member

    Joined:
    31 Jan 2013
    Messages:
    17
    Likes Received:
    0
    Reputations:
    0
    А если от 100 до 10000, то считаешь от 1 до 9900 и прибавляешь 100.
     
  6. fl00der

    fl00der Moderator

    Joined:
    17 Dec 2008
    Messages:
    1,028
    Likes Received:
    306
    Reputations:
    86
    100+random(9900)
     
    _________________________
  7. kolored

    kolored New Member

    Joined:
    16 Sep 2009
    Messages:
    18
    Likes Received:
    1
    Reputations:
    0
    Code:
    i := Random ( 9900 )+100;
    или

    Code:
    uses math;
    ...
    randomize;
    i := RandomRange( 100, 100000);
    Странный вопрос. Это есть в любой книге, любом мане и гугл об этом не молчит.
     
Loading...