Lightoj 1414 Feb 29

Problem Link:


Hints:

if 2nd given month is not feb and january ,i will increment the value by 1

and if the first given month is jan or feb and date is less then 29 then i will decrement the value by 1

then for every year i will calculate the difference using a function

let y and yy are two years &&yy>=y &&passing yy and y-1 to function

int leap(int yy,int y,int x)
{
     return yy/x-y/x;
}


Then calculations

 

View Code
#include 

using namespace std;

int month(string s)
{
string months[]={" ","January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
vectorv(months,months+13);
vector::iterator it=find(v.begin(),v.end(),s);
return distance(v.begin(), it);
}
int leap(int y,int yy,int x)
{
	
	return y/x-yy/x;
}

int main() {
		int n,d,dd,y,yy,cs=1;
		char a[24],b[24];
		cin>>n;
		while(n--)
		{
 scanf("%s %d, %d",a,&d,&y);
			scanf("%s %d, %d",b,&dd,&yy);
			int m,mm;
		        m=month(a);
			mm=month(b);
			if(m>2) y++;
			if(mm

 

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s