Home > Back-end >  The eldest brother how make this
The eldest brother how make this

Time:10-07

CodePudding user response:

Yo want to step, I want to see

CodePudding user response:

Srand ((unsigned int) time (NULL));
Int n1=rand () % 100;//double-digit
Int (n=11) (rand () % * (rand () % 2==1? 1:1);//0 to 10 random by 1

CodePudding user response:

refer to the second floor qybao response:
srand ((unsigned int) time (NULL));
Int n1=rand () % 100;//double-digit
Int (n=11) (rand () % * (rand () % 2==1? 1:1);//0 to 10 random by 1

Thank you ha ha ha ha

CodePudding user response:

1 rand () % 90 + 10 result is [10, 99]
2 (rand () % 21) - 10, the result is [- 10, 10]

Rand () % 100, the result is never come 100, only 99, the minimum is 0
So to double digits, and [to 10, 10] are need to do some extra processing

CodePudding user response:

Fun
reference 4 floor response:
1 rand () % 90 + 10 result is [10, 99]
2 (rand () % 21) - 10, the result is [- 10, 10]

Rand () % 100, the result is never come 100, only 99, the minimum is 0
So to double digits, and [- 10, 10] all need to do some extra processing

Thank you for your gnome male -"
  • Related