1122 - begin.min = 0; } if(begin.hour >=720)...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<cstdio> #include<iostream> using namespace std; struct Time { int hour; int min; }; Time begin,end; //set 720 degree as a circle //each between clock has an 60 degree t.hour %= 12; t.hour *= 60; t.hour += t.min; t.min *= 12; } int simulate(){ int ret =0; if(begin.hour == begin.min) ret ++; while(begin.hour != end.hour || begin.min != end.min){ ret++; } begin.min += 12; begin.hour += 1; if(begin.min >= 720){
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: begin.min = 0; } if(begin.hour &gt;=720) begin.hour = 0; } return ret; } int main(){ int t = 0; printf(&quot;Program 3 by team X\n&quot;); printf(&quot;Initial time Final time Passes\n&quot;); while(cin&gt;&gt;begin.hour&gt;&gt;begin.min&gt;&gt;end.hour&gt;&gt;end.min){ printf(&quot; %02d:%02d %02d:%02d &quot;, begin.hour,begin.min,end.hour,end.min); parse(begin); parse(end); t = simulate(); printf(&quot;%2d\n&quot;,t); } printf(&quot;End of program 3 by team X\n&quot;); return 0; }...
View Full Document

Ask a homework question - tutors are online