Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <conio.h>
- #include <time.h>
- using namespace std;
- void main() {
- srand(unsigned(time(NULL)));
- int a[6] = { 5, 9, 10, 15, 25, 26 };
- int b[6] = { 0 };
- int n = 6;
- for (int i = 0; i < 5;) {
- int random = rand() % 6;
- bool enter = true;
- for (int index = 0; index < 6; index++) {
- if (a[random] == b[index]) {
- enter = false;
- break;
- }
- }
- if (enter) {
- b[i] = a[random];
- i++;
- }
- }
- for (int i = 0; i < n - 1; i++) {
- cout << b[i]<<" ";
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement