Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- int main() {
- srand(time(NULL));
- int arr[6];
- int num;
- bool already;
- for (int i = 0; i < 6; i++) {
- already = false;
- num = 1 + rand() % (49 - 1 + 1);
- for (int j = 0; j < 6; j++) {
- if (arr[j] == num) {
- already = true;
- }
- }
- if (already == true) {
- i--;
- }
- else {
- arr[i] = num;
- }
- }
- cout << "Our numbers:\n";
- for (int i = 0; i < 6; i++) {
- cout << arr[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement