大蠢驴博客

好好学习,天天向上。

0%

知识复习

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
#include <random>
#include <vector>
#include <utility>
#include <string>
#include <iostream>

static std::vector<std::pair<std::string, int>> books_data = {
{"C++ Primer", 764},
{"深入理解计算机系统", 725},
{"高等数学第七版 上册", 22},
};

int main(int argc, char* args[])
{
std::random_device random;
std::mt19937 gen(random());

std::uniform_int_distribution<> distri_books(0, books_data.size() - 1);
int book = distri_books(gen);
std::uniform_int_distribution<> distri_pages(1, books_data[book].second - 1);
int page = distri_pages(gen);

std::cout << "今天需要回顾:" << books_data[book].first << "的" << page << "页。 \n";

return 0;
}