-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
32 lines (27 loc) · 881 Bytes
/
main.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
#include <array>
#include <cstdio>
#include <iostream>
#include <random>
#include <string>
int main() {
size_t pokemons = 0;
std::array<bool, 3> starters;
for (std::string line; std::getline(std::cin, line);) {
unsigned int index;
if (sscanf(line.c_str(), ".starters[%u]=", &index) == 2
&& index < starters.size()) {
starters[index] = true;
} else {
if (sscanf(line.c_str(), ".pokemons[%u]", &index) == 1)
pokemons = pokemons < index+1 ? index+1 : pokemons;
std::cout << line << "\n";
}
}
std::default_random_engine gen;
std::uniform_int_distribution<size_t> dist(0, pokemons-1);
for (size_t i = 0; i < starters.size(); i++) {
if (!starters[i])
continue;
std::cout << ".starters[" << i << "]=" << dist(gen) << "\n";
}
}