aboutsummaryrefslogtreecommitdiff
path: root/semestr-4/sieci/warsztaty8/185952.cpp
blob: 4dc8f725f5aa3038f7a8a980715b4c891edb29a3 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include<bits/stdc++.h>
using namespace std;

int tab[13]= {31,28,31,30,31,30,31,31,30,31,30,31};

int czas(string dt,string g)
{
    int lata,msc,dni;
    long long c1,c2;
    lata=dt[0]*1000+dt[1]*100+dt[2]*10+dt[3]-'0'*1111-1900;
    msc=dt[5]*10+dt[6]-11*'0';
    dni=0;
    c1=(dt[8]*10+dt[9]-11*'0'-1)*86400;
    c1+=(g[0]*10+g[1]-11*'0')*3600;
    c1+=(g[3]*10+g[4]-11*'0')*60;
    c1+=g[6]*10+g[7]-11*'0';
    for(int i=0; i<lata*12+msc-1; i++)
    {
        if(i%48==0 && dt[1]!=9  && dt[2]!=0  && dt[3]!=0)
        {
            c1+=86400;
        }
        c1+=tab[i%12]*86400;
    }
    return c1;
}
int main()
{
    long long wynik=0;
    string dt,g;
    cin >> dt >> g;
    long long w1=czas(dt,g);
    cin >> dt >> g;
    int n;
    cin >> n;
    long long w2=czas(dt,g);
    long long w=w2-w1;
    int d=w/86400;
    w%=86400;
    int h=w/3600;
    w%=3600;
    int m=w/60;
    w%=60;
    int s=w;
    if(d!=0)
    {
        cout << d << ' ';
        if(d==1)
        {
            cout << "dzien ";
        }
        else
        {
            cout << "dni ";
        }
    }
    if(h!=0)
    {
        cout << h << ' ';
        if(h==1)
        {
            cout << "godzina ";
        }
        else if(h%10>=2 && h%10<=4 && (h<=11 || h>=15))
        {
            cout << "godziny ";
        }
        else
        {
            cout << "godzin ";
        }

    }
    if(m!=0)
    {
        cout << m << ' ';
        if(m==1)
        {
            cout << "minuta ";
        }
        else if(m%10>=2 && m%10<=4 && (m<=11 || m>=15))
        {
            cout << "minuty ";
        }
        else
        {
            cout << "minut ";
        }

    }
    if(s!=0)
    {
        cout << s << ' ';
        if(s==1)
        {
            cout << "sekunda ";
        }
        else if(h%10>=2 && h%10<=4 && (h<=11 || h>=15))
        {
            cout << "sekundy ";
        }
        else
        {
            cout << "sekund ";
        }

    }
    cout << "\n";
}