fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int clc(string tm,string zone)
  7. {
  8. int sum = 0;
  9.  
  10. if(zone == "PM"){
  11. if(tm[0] != '1' && tm[1] != '2') sum = 12*3600;
  12. }
  13.  
  14. int s = 0,d=3600;
  15. for(int i=0;i<tm.size();i++){
  16. if(tm[i]==':'){
  17. sum += s * d;
  18. d /= 60;
  19. s = 0;
  20. }
  21. else s = (s*10) + tm[i]-'0';
  22. }
  23. sum += s;
  24. return sum;
  25. }
  26. int main()
  27. {
  28.  
  29. string str[200];
  30. int ttl = 0,days=0;
  31.  
  32. while(cin>>str[0]){
  33. days++;
  34. for(int i=1;i<=12;i++) cin>>str[i];
  35. ttl += clc(str[10],str[11]) - clc(str[7],str[8]);
  36. }
  37.  
  38. int avg = ttl / days;
  39.  
  40. cout<<"Total Attendance : "<<days<<" Days"<<endl<<endl;
  41.  
  42.  
  43. int hour = ttl / 3600; ttl %= 3600;
  44. int minute = ttl / 60; ttl %= 60;
  45. cout<<"Total Office Time : "<<endl;
  46. cout<<" "<<hour<<" Hours "<<minute<<" Minutes "<<ttl<<" Seconds"<<endl<<endl;
  47.  
  48. int h = avg / 3600; avg %= 3600;
  49. int m = avg / 60; avg %= 60;
  50. int s = avg;
  51. cout<<"Average Time Per Day : "<<endl;
  52. cout<<" "<<h<<" Hours "<<m<<" Minutes "<<s<<" Seconds"<<endl<<endl;
  53.  
  54.  
  55. }
  56.  
Success #stdin #stdout 0.01s 5280KB
stdin
						
16 Oct 2024	8:10:00 AM	4:00:00 PM	7:49:35 AM	N	4:14:01 PM	N
19 Oct 2024	8:10:00 AM	4:00:00 PM	7:47:15 AM	N	4:21:20 PM	N
20 Oct 2024	8:10:00 AM	4:00:00 PM	7:42:59 AM	N	6:27:17 PM	N
21 Oct 2024	8:10:00 AM	4:00:00 PM	12:19:41 PM	Y	5:45:43 PM	N
22 Oct 2024	8:10:00 AM	4:00:00 PM	7:58:56 AM	N	4:12:49 PM	N
23 Oct 2024	8:10:00 AM	4:00:00 PM	8:03:51 AM	N	4:02:45 PM	N
24 Oct 2024	8:10:00 AM	4:00:00 PM	12:23:20 PM	Y	4:14:46 PM	N
26 Oct 2024	8:10:00 AM	4:00:00 PM	7:50:45 AM	N	4:15:22 PM	N
27 Oct 2024	8:10:00 AM	4:00:00 PM	7:53:54 AM	N	4:13:46 PM	N
29 Oct 2024	8:10:00 AM	4:00:00 PM	7:44:45 AM	N	7:26:41 PM	N
30 Oct 2024	8:10:00 AM	4:00:00 PM	7:48:34 AM	N	4:16:22 PM	N
31 Oct 2024	8:10:00 AM	4:00:00 PM	12:19:36 PM	Y	6:39:57 PM	N
02 Nov 2024	8:10:00 AM	4:00:00 PM	7:44:58 AM	N	2:43:17 PM	Y
03 Nov 2024	8:10:00 AM	4:00:00 PM	7:49:26 AM	N	4:16:38 PM	N
04 Nov 2024	8:10:00 AM	4:00:00 PM	12:07:05 PM	Y	5:34:11 PM	N
05 Nov 2024	8:10:00 AM	4:00:00 PM	7:47:14 AM	N	4:14:25 PM	N
06 Nov 2024	8:10:00 AM	4:00:00 PM	7:47:21 AM	N	4:15:23 PM	N
09 Nov 2024	8:10:00 AM	4:00:00 PM	7:43:08 AM	N	5:46:14 PM	N
10 Nov 2024	8:10:00 AM	4:00:00 PM	7:46:01 AM	N	6:11:11 PM	N
11 Nov 2024	8:10:00 AM	4:00:00 PM	12:41:53 PM	Y	5:52:27 PM	N
12 Nov 2024	8:10:00 AM	4:00:00 PM	7:41:02 AM	N	5:48:35 PM	N
13 Nov 2024	8:10:00 AM	4:00:00 PM	7:43:42 AM	N	8:04:57 PM	N
stdout
Total Attendance : 22 Days

Total Office Time : 
                    182 Hours 23 Minutes 6 Seconds

Average Time Per Day : 
                       8 Hours 17 Minutes 24 Seconds