forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1122Clock.cpp
More file actions
50 lines (45 loc) · 1.15 KB
/
1122Clock.cpp
File metadata and controls
50 lines (45 loc) · 1.15 KB
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
#include <iostream>
using namespace std;
int main(void){
int x1,y1,x2,y2,a1,a2,n,i;
cout<<"Program 3 by team X"<<endl;
cout<<"Initial time Final time Passes"<<endl;
while(cin>>x1>>y1>>x2>>y2){
cout<<" ";
if(x1>9) cout<<x1;
else cout<<"0"<<x1;
cout<<":";
if(y1>9) cout<<y1;
else cout<<"0"<<y1;
cout<<" ";
if(x2>9) cout<<x2;
else cout<<"0"<<x2;
cout<<":";
if(y2>9) cout<<y2;
else cout<<"0"<<y2;
cout<<" ";
n=0;
if(x1==x2&&y1<y2){
a1=x1%12;
a2=x1%12;
if( 60*a1>11*y1 && 60*a2<11*y2 ) n++;
}
else{
a1=x1%12;
a2=x2%12;
if(60*a1>11*y1&&a1!=11) n++;
i=x1+1;
while(1){
if(i>12) i=1;
if(i==x2) break;
if(i!=11) n++;
i++;
}
if(60*a2<11*y2) n++;
}
if(n>9) cout<<n<<endl;
else cout<<" "<<n<<endl;
}
cout<<"End of program 3 by team X"<<endl;
return 0;
}