[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] 'sandsynligheds'-funktion



sslug@sslug writes:

>  Jeg skal lave en sandsynligheds-funktion, der givet et tal imellem 0 og
>  100, returnerer 1 med <tal>% sandsynlighed, og 0 med <100 - tal>%
>  sandsynlighed.

rand() returnerer et tilfældigt heltal mellem 0 og RAND_MAX. Så kan du
tjekke på om rand returnerer et tal sørre eller mindre end
((tal/100) * RAND_MAX) og på baggrund af det returnerer 0 eller 1.


Overvej lidt hvordan du afrunder, det kan påvirke om dine sikre
hændelser (Det givne tal er 0 eller 100) virkelig er sikre eller kun
*næsten* sikre hændelser.

-- 
SSLUGs julekalender - hver dag fra den 1. til den 24. december
   http://www.sslug.dk/julekalender/


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *