input: 8 numbers

output:a random number between 1-100 base on the input numbers

any idea for doing this ?

Printable View

- 11-05-2012king_zartrandom number
input: 8 numbers

output:a random number between 1-100 base on the input numbers

any idea for doing this ? - 11-05-2012camel-man
Post some code first. As far as the random number goes, read this SRAND - set seed for random number generation.

- 11-05-2012king_zart
i know how s rand and rand work but if i use them its not base on the numbers!

i want the program choose random numbers in some rule

for example if more than half of numbers are lower than 1000 the chance for give output numbers that are lower than 50 increese by 20 percent or sth like this! - 11-05-2012qny
Why?

Anyway, here's an approach. (Why anyone would use it rather than a direct rand() value is beyond me though)

Code:`int randbased(input *array) // input is in array[0] to array[7]`

{

int k, s = 0;

for (k = 0; k < 8; k++) s += input[k];

for (k = 0; k < s; k++) rand(); /* ignore s random numbers */

return rand();

}

- 11-05-2012Nominal Animal
We are neither telepathic nor omniscient, you know.

You need to define those rules for us to be able to help you.

If you don't know the rules, but can show a complete set of inputs and outputs, then we can help you deduce the rules. Then we can help you implement those rules in code. But we cannot divine your wishes.

Please be specific, as vague partial examples are just frustrating to everyone. We need detailed, specific information, to help you. - 11-05-2012iMalc
- 11-06-2012king_zart
as i said before i want the program do this...

Code:`#include <stdio.h>`

int main()

{

int a[8];

int i,b;

for(i=0;i<8;i++)

scanf("%d",&a[i]);

for(i=0;i<8;i++)

if(a[i]<100)

b++;

if(b>4)

//give a random number lower than 200 that its chance for become lower than 100 is 2times more than becom higher than 100

{}

}

- 11-06-2012qny
Generate a random number between 0 and 300.

If it is greater or equal to 200, subtract 200, getting a new number between 0 and 100.

Result: numbers between 0 and 100 are twice more likely to come up than numbers between 100 and 200. - 11-06-2012iMalc
Yeah I can't help you, you keep adding random weird requirements every time you post.