Thread: Beginner!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    13

    Beginner!

    Hello!

    I'm trying to make a bulls function! On average I would like it to hit the Bull 70% of the time and the other 30% (miss) between 1 to 20. As you can see I have the basic code, but I'm just learning so don't really understand what each part does.

    Code:
    int Bull() 
    {
            int percent = rand()%100; //lower percent is more throws needed
            int r = rand()%100; //lower r is less throws needed
            if(r<percent)        // hit
            return 50;
            else            // miss
            return 1 + rand()%20;
    }
    Thanks in advance! :-)
    Last edited by Valdo; 03-14-2012 at 07:57 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. anyone can help?beginner nd help...
    By silent in forum C++ Programming
    Replies: 6
    Last Post: 10-01-2010, 09:20 AM
  2. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM
  3. Beginner's help
    By rekiller in forum Game Programming
    Replies: 3
    Last Post: 03-17-2003, 08:06 AM
  4. beginner ?
    By braincrash in forum C Programming
    Replies: 2
    Last Post: 02-18-2003, 03:33 AM