Results 1 to 7 of 7

Thread: C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User rumen_33's Avatar
    Join Date: May:2007
    Location: Canada
    Posts: 137

    C++

    . - , , 1, 1% . , 100 1. .
    |Asus P5K Premium WiFi|Intel C2D E6750|Kingston 2x1GB@667MHz|Seagate 250GB+500GB|Coolmax CP 500W|Asus EN 8800 GTS 320MB|

  2. #2
    Registered User
    Join Date: Oct:2003
    Location:
    Posts: 4,317

  3. #3
    philosophus duratea icaci's Avatar
    Join Date: Oct:2006
    Location: Aachen
    Posts: 2,698
    Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others

  4. #4
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    1 N :
    Code:
    int once_in_n_times(int n) {
        return (rand()%n == n-1);
    }
    1 0 1 (1 - 100% )

    Code:
    int probability_test(double probability)
    {
        return (drand48() < probability);
    }
    drand48 GNU libc ( stdlib.h). , :

    Code:
    double drand48() { return (rand() % 31337) / 31337.0; }
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  5. #5
    Registered User rumen_33's Avatar
    Join Date: May:2007
    Location: Canada
    Posts: 137
    . !
    |Asus P5K Premium WiFi|Intel C2D E6750|Kingston 2x1GB@667MHz|Seagate 250GB+500GB|Coolmax CP 500W|Asus EN 8800 GTS 320MB|

  6. #6
    Executor Lan's Avatar
    Join Date: Nov:2005
    Location:
    Posts: 3,304
    , ?
    I mourn thee by dusk | I mourn thee by dawn
    Crave for thy gloss | to seek the silent glades beyond

  7. #7
    Registered User rumen_33's Avatar
    Join Date: May:2007
    Location: Canada
    Posts: 137
    , if , , . , . !

    #include <cstdlib>
    #include <iostream>

    using namespace std;

    int once_in_n_times(int n)
    {
    int number_two = rand()% 4 + 1;
    int number = rand()% 100 + 1;
    string event;


    if (number_two == 1)
    event = "Event 1";
    if (number_two == 2)
    event = "Event 2";
    if (number_two == 3)
    event = "Event 3";
    if (number_two == 4)
    event = "Event 4";

    if (number == 1)
    cout <<event <<endl;
    else
    cout <<"Nothing happened" <<endl;

    }

    // MAIN
    int main()
    {
    srand(time(0));
    once_in_n_times(100);

    system("PAUSE");
    return(0);
    }

    , anrieff , !

    , !

    , - , ! , 1% 1, event.
    Last edited by rumen_33; 22nd December 2008 at 08:08.
    |Asus P5K Premium WiFi|Intel C2D E6750|Kingston 2x1GB@667MHz|Seagate 250GB+500GB|Coolmax CP 500W|Asus EN 8800 GTS 320MB|

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |