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
01 Oct 2024	8:10:00 AM	4:00:00 PM	7:50:28 AM	N	5:45:40 PM	N
02 Oct 2024	8:10:00 AM	4:00:00 PM	7:42:47 AM	N	4:20:03 PM	N
03 Oct 2024	8:10:00 AM	4:00:00 PM	7:45:28 AM	N	4:12:13 PM	N
05 Oct 2024	8:10:00 AM	4:00:00 PM	7:57:52 AM	N	6:45:55 PM	N
06 Oct 2024	8:10:00 AM	4:00:00 PM	7:52:54 AM	N	6:31:47 PM	N
07 Oct 2024	8:10:00 AM	4:00:00 PM	12:23:49 PM	Y	6:48:24 PM	N
08 Oct 2024	8:10:00 AM	4:00:00 PM	7:51:44 AM	N	4:11:06 PM	N
09 Oct 2024	8:10:00 AM	4:00:00 PM	7:48:58 AM	N	4:21:25 PM	N
12 Oct 2024	8:10:00 AM	4:00:00 PM	7:44:34 AM	N	6:40:50 PM	N
14 Oct 2024	8:10:00 AM	4:00:00 PM	12:22:19 PM	Y	6:54:58 PM	N
15 Oct 2024	8:10:00 AM	4:00:00 PM	7:49:05 AM	N	4:16:18 PM	N
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
stdout
Total Attendance : 17 Days

Total Office Time : 
                    147 Hours 0 Minutes 19 Seconds

Average Time Per Day : 
                       8 Hours 38 Minutes 50 Seconds