Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<vector>
- using namespace std;
- /*
- We going data to stream &ostream
- */
- void dump(const vector<vector<string>>& data) {
- int day;
- cin >> day;
- for (auto s : data[day - 1]) {
- cout << s << ' ';
- }
- }
- /*
- We added new string for section vector with index [day-1]
- */
- void add(vector<vector<string>>& data) {
- int day;
- string work;
- cin >> day >> work;
- data[day - 1].push_back(work);
- }
- void next(vector<vector<string>>& data, const vector<int>& month, int& mi) {
- if (mi == 11) {//If year is ended, we defined new month
- mi = 0;
- }
- else if (mi != 11) {
- ++mi;
- }
- if (month[mi] >= month[mi - 1]) {//if new month has a bigger index, we only using resize
- data.resize(month[mi]);
- }
- else {
- vector<string> temp;
- int diff = month[mi - 1] - month[mi];//search, a lot of many indexating vectors are diffirence
- for (int i = 0; i < diff; ++i) {
- /*
- !!!!!!!!!!!!!!!!!!!1
- In this code we not have a data on vector temp
- */
- for (auto& s : data[month[mi] - 1 - i]) {
- temp.push_back(s);
- }
- }
- //???????????
- for (auto s : temp) {
- cout << s << ' ';
- }
- }
- }
- int main() {
- /*****************
- Declaration using variables on upper function
- *********************************/
- vector<vector<string>> data(31);
- int mi = 0;
- const vector<int> month = { 31,28,31,30,31,30,31,31,30,31,30,31 };
- /*****************************
- Declarate template variables for select work code
- *********************/
- int n;
- string sel;
- cin >> n;
- /*************************************************/
- for (int i = 0; i < n; ++i) {
- cin >> sel;
- if (sel == "ADD") {
- add(data);
- }
- else if (sel == "DUMP") {
- dump(data);
- }
- else if (sel == "NEXT") {
- next(data, month, mi);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement