恋爱计时器

恋爱计时器

#include <stdio.h>
#include <stdlib.h>
struct date
{
 int year;
 int mouth;
 int day;
};
int main()
{
 int dayst(struct date a, struct date b);
 int xingqi(struct date a, int z);
 struct date a, b;
 int x, y;
 printf("                                   ");
 scanf_s("%d %d %d", &a.year, &a.mouth, &a.day);
 printf("                                   ");
 scanf_s("%d %d %d", &b.year, &b.mouth, &b.day);
 x = dayst(a, b);
 printf("                             今天是我们相爱的%d天\n                                  老婆我爱你!\n                                  I love you!\n", x);
 printf("                 ******            ***   ***              **            ** \n");
 printf("                   **             ***** *****             **            ** \n");
 printf("                   **            *************            **            ** \n");
 printf("                   **             ***********             **            ** \n");
 printf("                   **              *********              **            ** \n");
 printf("                   **               *******               **            ** \n");
 printf("                   **                *****                 **          **  \n");
 printf("                   **                 ***                    **      **   \n");
 printf("                 ******                *                       ******     \n");
 printf("\n\n");
 printf("  *********   *       *   *********   ***   *   ***  *   * *****   *    *  ***  *      *    ***\n");
 printf("        *     *       *   *            *    *  *   *       *        *  *  *   * *      *    ***\n");
 printf("      *       *********   ********     *    *  *   *  * *  *****      *   *   * *      *    ***\n");
 printf("    *         *       *   *            *    *  *   *       *         *    *   * *      *    ***\n");
 printf("  *********   *       *   *           ***   **  ***    *   *****    *      ***   ******      *\n\n");
 system("pause");
 system("pause");
 return 0;
}
int dayst(struct date a, struct date b)
{
 int i, j, x = 0, y = 0, day=0, d[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 }, c[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
 if ((a.year % 4 == 0 && a.year % 100 != 0) || a.year % 400 == 0)
  for (i = 0; i<a.mouth - 1; i++)
   x = x + c[i];
 else
  for (i = 0; i<a.mouth - 1; i++)
   x = x + d[i];
 x = x + a.day;
 if ((b.year % 4 == 0 && b.year % 100 != 0) || b.year % 400 == 0)
  for (i = 0; i<b.mouth - 1; i++)
   y = y + c[i];
 else
  for (i = 0; i<b.mouth - 1; i++)
   y = y + d[i];
 y = y + b.day;
 if (a.year == b.year) day = y - x;
 else
 {
  if ((a.year % 4 == 0 && a.year % 100 != 0) || a.year % 400 == 0)
   day = 366 - x + 1;
  else
   day = 365 - x + 1;
  for (i = a.year + 1; i < b.year; i++)
   if (( i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
    day = 366 + day;
   else
    day = 365 + day;
  day = day + y;
 }
 return day;
}
#include <stdio.h>
#include <stdlib.h>
struct date
{
	int year;
	int mouth;
	int day;
};
int main()
{
	int dayst(struct date a, struct date b);
	int xingqi(struct date a, int z);
	struct date a, b;
	int x, y;
	printf("                                   ");
	scanf_s("%d %d %d", &a.year, &a.mouth, &a.day);
	printf("                                   ");
	scanf_s("%d %d %d", &b.year, &b.mouth, &b.day);
	x = dayst(a, b);
	printf("                             今天是我们相爱的%d天\n                                  老婆我爱你!\n                                  I love you!\n", x);
	printf("                 ******            ***   ***              **            ** \n");
	printf("                   **             ***** *****             **            ** \n");
	printf("                   **            *************            **            ** \n");
	printf("                   **             ***********             **            ** \n");
	printf("                   **              *********              **            ** \n");
	printf("                   **               *******               **            ** \n");
	printf("                   **                *****                 **          **  \n");
	printf("                   **                 ***                    **      **   \n");
	printf("                 ******                *                       ******     \n");
	printf("\n\n");
	printf("  *********   *       *   *********   ***   *   ***  *   * *****   *    *  ***  *      *    ***\n");
	printf("        *     *       *   *            *    *  *   *       *        *  *  *   * *      *    ***\n");
	printf("      *       *********   ********     *    *  *   *  * *  *****      *   *   * *      *    ***\n");
	printf("    *         *       *   *            *    *  *   *       *         *    *   * *      *    ***\n");
	printf("  *********   *       *   *           ***   **  ***    *   *****    *      ***   ******      *\n\n");
	system("pause");
	system("pause");
	return 0;
}
int dayst(struct date a, struct date b)
{
	int i, j, x = 0, y = 0, day=0, d[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 }, c[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	if ((a.year % 4 == 0 && a.year % 100 != 0) || a.year % 400 == 0)
		for (i = 0; i<a.mouth - 1; i++)
			x = x + c[i];
	else
		for (i = 0; i<a.mouth - 1; i++)
			x = x + d[i];
	x = x + a.day;
	if ((b.year % 4 == 0 && b.year % 100 != 0) || b.year % 400 == 0)
		for (i = 0; i<b.mouth - 1; i++)
			y = y + c[i];
	else
		for (i = 0; i<b.mouth - 1; i++)
			y = y + d[i];
	y = y + b.day;
	if (a.year == b.year) day = y - x;
	else
	{
		if ((a.year % 4 == 0 && a.year % 100 != 0) || a.year % 400 == 0)
			day = 366 - x + 1;
		else
			day = 365 - x + 1;
		for (i = a.year + 1; i < b.year; i++)
			if (( i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
				day = 366 + day;
			else
				day = 365 + day;
		day = day + y;
	}
	return day;
}

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值