Results 1 to 7 of 7
Thread: C++
Hybrid View
-
17th December 2008 08:32 #1
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|
-
17th December 2008 08:59 #2Registered User
Join Date: Oct:2003
Location:
Posts: 4,317
-
17th December 2008 11:37 #3
, Numerical recipes in C, 7.
Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others
-
17th December 2008 16:59 #4
1 N :
1 0 1 (1 - 100% )Code:int once_in_n_times(int n) { return (rand()%n == n-1); }
drand48 GNU libc ( stdlib.h). , :Code:int probability_test(double probability) { return (drand48() < probability); }
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
-
19th December 2008 03:03 #5
. !
|Asus P5K Premium WiFi|Intel C2D E6750|Kingston 2x1GB@667MHz|Seagate 250GB+500GB|Coolmax CP 500W|Asus EN 8800 GTS 320MB|
-
19th December 2008 13:20 #6
, ?
I mourn thee by dusk | I mourn thee by dawn
Crave for thy gloss | to seek the silent glades beyond
-
22nd December 2008 08:01 #7
, 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|




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in