Exemple #1
0
int main()
{
  int y,m,d1;
  int n,x;
  d1=DAYof_INITYR;
  y=INITYR;
  int ans=0;
  while(y!=FINLYR+1)
  {
	m=1;
	while(m!=13)
	{
	  n=noofdays(m,y);
	  x=n%7;
	  d1=incday(x,d1);
	  if(d1==reqDAY)
		ans++;
	  m++;
	}
	y++;
	if(y==INITYR)
	  ans=0;
  }
  printf("\n%d\n",ans);
  return 0;
}
int between_days(struct node *date1head, struct node *date2head){

	struct node *month1, *day1, *year1,*month2,*day2,*year2;
	int count = 0,res=0;
	if (date1head != NULL&&date2head != NULL)
	{
		day1 = date1head;
		while (count != 2)
		{
			date1head = date1head->next;
			count++;
		}
		month1 = date1head;
		count = 0;
		while (count != 2)
		{
			date1head = date1head->next;
			count++;
		}
		year1 = date1head;
		count = 0;
		day2 = date2head;
		while (count != 2)
		{
			date2head = date2head->next;
			count++;
		}
		month2 = date2head;
		count = 0;
		while (count != 2)
		{
			date2head = date2head->next;
			count++;
		}
		year2 = date2head;
		res = noofdays(day1, day2, month1, month2, year1, year2);
		if (res == 0)
		{
			return -1;
		}
		else
		{
			return res;
		}
	}
	else
	{
		return -1;
	}
}