中国开发网: 论坛: 程序员情感CBD: 贴子 249305
周星驰
楼上的没明白的,我都给出终极正解了还没明白,看看这段程序你就会明白了。。。
run run

void PlaySelect()
{
srand( (unsigned)time( NULL ) );
const int loop_count = 10000;

int total_first_hit = 0;
int total_change_hit = 0;

for ( int i = 0; i < loop_count; ++ i )
{
int car = rand() % 3;
int first_select = rand() % 3;
if ( first_select == car )
{
++ total_first_hit;
continue;
}
++ total_change_hit;
}

cout << "total_first_hit = " << total_first_hit << endl;
cout << "total_change_hit = " << total_change_hit << endl;
}

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录