// Generate a random number. If the value of the random number is multiple of 3, // then display the old random number that is already displayed and display the // current random number in one line. #include #include #include void check_random(unsigned &, unsigned); int main() { unsigned before, now; int counter = 0; srand (time(0)); before = 0; while (counter < 20) { now = rand(); check_random(before, now); counter++; } return 0; } void check_random(unsigned &old_random, unsigned cur_random) { if ((cur_random % 3) == 0) { cout << "old random : " << old_random << " and current random : " << cur_random << "\n"; old_random = cur_random; } }