Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- void update(int& hh1, int& mm1, int& ss1) {
- if (ss1 < 59) {
- ss1++;
- }
- else if (mm1 < 59) {
- mm1++;
- ss1 = 0;
- }
- else if (hh1 < 23) {
- hh1++;
- mm1 = 0;
- ss1 = 0;
- }
- }
- void count(int kk, vector<int>& m) {
- if (kk < 10) {
- m[0]++;
- m[kk % 10]++;
- }
- else {
- m[kk / 10]++;
- m[kk % 10]++;
- }
- }
- int main() {
- std::ifstream fin("input.txt");
- std::ofstream fout("output.txt");
- string time_1, time_2;
- fin >> time_1 >> time_2;
- int hh1 = stoi(time_1.substr(0, 2));
- int hh2 = stoi(time_2.substr(0, 2));
- int mm1 = stoi(time_1.substr(3, 2));
- int mm2 = stoi(time_2.substr(3, 2));
- int ss1 = stoi(time_1.substr(6, 2));
- int ss2 = stoi(time_2.substr(6, 2));
- vector<int> m(10, 0);
- while (hh1 != hh2 || mm1 != mm2 || ss1 != ss2) {
- count(hh1, m);
- count(mm1, m);
- count(ss1, m);
- update(hh1, mm1, ss1);
- }
- count(hh1, m);
- count(mm1, m);
- count(ss1, m);
- for (int i = 0; i < 10; i++) {
- fout << m[i] << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment