周星驰:
楼上的没明白的,我都给出终极正解了还没明白,看看这段程序你就会明白了。。。
[阅读: 940] 2005-11-30 03:02:14
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;
}