-
Notifications
You must be signed in to change notification settings - Fork 0
/
20240229.cpp
43 lines (35 loc) · 924 Bytes
/
20240229.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
int lotte[7];
for (int i = 0; i < 7; i++) {
srand(time(NULL) + i*100);
lotte[i] = rand() % 9 + 1;
while (true) {
bool repeated = false;
for (int j = i - 1; j >= 0; j--) {
if (lotte[i] == lotte[j]) repeated = true;
}
if (!repeated) break;
}
}
for (int i = 0; i < 7; i++) {
cout << "" << lotte[i] << " ";
}
cout << endl;
for (int i = 6; i >= 0; i--) {
for (int j = 0; j < i; j++) {
if (lotte[j] < lotte[j + 1]) {
int temp = lotte[j + 1];
lotte[j + 1] = lotte[j];
lotte[j] = temp;
}
}
}
for (int i = 0; i < 7; i++) {
cout << "" << lotte[i] << " ";
}
return 0;
}