From 8232b71982b9e6299b43ed2517629ea66c055ef1 Mon Sep 17 00:00:00 2001
From: ShivamVerma380 <71377475+ShivamVerma380@users.noreply.github.com>
Date: Tue, 27 Oct 2020 21:41:18 +0530
Subject: [PATCH] Pills Dosage using C++
First, check whether a given year is a leap year or not.
If a month is of 30 days then taking pills will continue to next month as there are no consecutive odd days.(i.e. 04,06,09,11)
If a month is of 31 days then taking pills will not continue to next month as there are consecutive odd days 31st and 1st .(i.e. 01,03,05,07,08,10,12)
In the case of February if it is of 28 days(i.e. nonleap year) it will continue to next month as there are no consecutive odd days. But for 29days February it will not continue to next month as there are consecutive odd days.
---
Pills Dosage | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
create mode 100644 Pills Dosage
diff --git a/Pills Dosage b/Pills Dosage
new file mode 100644
index 0000000..8577189
--- /dev/null
+++ b/Pills Dosage
@@ -0,0 +1,57 @@
+#include
+using namespace std;
+
+int leap(int year)
+{
+ if((year%4==0 && year%100!=0) || year%400==0)
+ return 1;
+ else
+ return 0;
+}
+int main() {
+ // your code goes here
+
+ int t;
+ cin>>t;
+ while(t--)
+ {
+ int y,m,d;
+ char c, cc;
+ int med;
+ cin>>y>>c>>m>>cc>>d;
+ if(leap(y))
+ {
+ if(m==2)
+ {
+ med = ((29-d)/2)+1;
+ }
+ else if(m==4 || m==6 || m==9 || m==11)
+ {
+ med = ((30-d+31)/2)+1;
+ }
+ else
+ {
+ med = ((31-d)/2)+1;
+ }
+ }
+ else
+ {
+ if(m==2)
+ {
+ med = ((28-d+31)/2)+1;
+ }
+ else if(m==4 || m==6 || m==9 || m==11)
+ {
+ med = ((30-d+31)/2)+1;
+ }
+ else
+ {
+ med = ((31-d)/2)+1;
+ }
+
+ }
+ cout<