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 Apr 2024	8:10:00 AM	4:00:00 PM	8:49:05 AM	Y	4:23:19 PM	N
16 Apr 2024	8:10:00 AM	4:00:00 PM	10:03:21 AM	Y	4:23:21 PM	N
17 Apr 2024	8:10:00 AM	4:00:00 PM	10:08:57 AM	Y	6:08:57 PM	N
18 Apr 2024	8:10:00 AM	4:00:00 PM	10:06:28 AM	Y	8:51:51 PM	N
21 Apr 2024	8:10:00 AM	4:00:00 PM	10:46:32 AM	Y	9:54:40 PM	N
22 Apr 2024	8:10:00 AM	4:00:00 PM	10:57:58 AM	Y	6:53:43 PM	N
23 Apr 2024	8:10:00 AM	4:00:00 PM	10:22:25 AM	Y	9:26:28 PM	N
24 Apr 2024	8:10:00 AM	4:00:00 PM	11:30:09 AM	Y	7:10:12 PM	N
25 Apr 2024	8:10:00 AM	4:00:00 PM	5:43:56 AM	N	5:33:09 PM	N
27 Apr 2024	8:10:00 AM	4:00:00 PM	10:56:32 AM	Y	6:41:55 PM	N
28 Apr 2024	8:10:00 AM	4:00:00 PM	9:51:13 AM	Y	6:35:27 PM	N
29 Apr 2024	8:10:00 AM	4:00:00 PM	10:14:52 AM	Y	8:16:03 PM	N
04 May 2024	8:10:00 AM	4:00:00 PM	11:11:26 AM	Y	9:09:30 PM	N
05 May 2024	8:10:00 AM	4:00:00 PM	9:28:33 AM	Y	7:27:00 PM	N
06 May 2024	8:10:00 AM	4:00:00 PM	10:04:00 AM	Y	4:27:12 PM	N
07 May 2024	8:10:00 AM	4:00:00 PM	10:25:11 AM	Y	7:25:58 PM	N
08 May 2024	8:10:00 AM	4:00:00 PM	10:16:42 AM	Y	4:18:18 PM	N
09 May 2024	8:10:00 AM	4:00:00 PM	10:39:10 AM	Y	8:12:25 PM	N
11 May 2024	8:10:00 AM	4:00:00 PM	10:46:14 AM	Y	8:26:17 PM	N
12 May 2024	8:10:00 AM	4:00:00 PM	10:50:02 AM	Y	6:45:06 PM	N
13 May 2024	8:10:00 AM	4:00:00 PM	10:39:01 AM	Y	4:43:49 PM	N
14 May 2024	8:10:00 AM	4:00:00 PM	9:56:25 AM	Y	4:24:58 PM	N
stdout
Total Attendance : 22 Days

Total Office Time : 
                    189 Hours 51 Minutes 26 Seconds

Average Time Per Day : 
                       8 Hours 37 Minutes 47 Seconds