CPP
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
//Enter a number for the size of an array (I normally use 5). The code will then look through the array and output every number that is bigger than another number to it's right. I made it so the random numbers in the array are between 0 and 1000. Probably not as efficient as possible but not too hard to understand (I hope xd). Like if you enjoyed :P
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
int y, len, y2, a, b;
cin >> y;
len = y;
y2 = y;
if (y < 2) {
cout << "input has to be bigger than 1";
return 0;
}
int x[y];
srand(time(0));
cout << "[";
for (int i; y > 0; y--) {
i = rand() % 1000;
x[y] = i;
cout << x[y];
if (y > 1) {
cout << ", ";
}
}
cout << "]";
y = len;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run