Advertisement
vlatkovski

Casovnik (Chasovnik) [државен '13]

Oct 13th, 2017
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. string tostr(int x) {
  5.     stringstream ss;
  6.     if (x < 10) ss << 0;
  7.     ss << x;
  8.     return ss.str();
  9. }
  10.  
  11. int main() {
  12.     int hh, mm;
  13.     cin >> hh >> mm;
  14.  
  15.     int cnt = 0;
  16.     string hs = tostr(hh), ms = tostr(mm);
  17.     for (int i = 0; i < 10; ++i) {
  18.         mm++;
  19.         if (mm == 60) {
  20.             mm = 0;
  21.             hh++;
  22.             if (hh == 24) {
  23.                 hh = 0;
  24.             }
  25.         }
  26.         string hs1 = tostr(hh), ms1 = tostr(mm);
  27.         for (int i = 0; i < 2; ++i) {
  28.             if (hs.at(i) != hs1.at(i)) cnt++;
  29.             if (ms.at(i) != ms1.at(i)) cnt++;
  30.         }
  31.         hs = hs1;
  32.         ms = ms1;
  33.     }
  34.  
  35.     cout << cnt;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement