慕粉4019594
2016-09-30 14:05:09浏览 6484
// ConsoleApplication6.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2016;
int month = 9;
int day = 30;
int today = 0;
int i = month - 1;//前面有i个月
switch (i)
{
case 0: today = 0;
break;
case 1: today += 31;
break;
case 2:
today += (28 + 31);
break;
case 3:
today += (31 + 28 + 31);
break;
case 4:
today += (31 + 28 + 31 + 30);
break;
case 5:
today += (31 + 28 + 31 + 30 + 31);
break;
case 6:
today += (31 + 28 + 31 + 30 + 31 + 30);
break;
case 7:
today += (31 + 28 + 31 + 30 + 31 + 30 + 31);
break;
case 8:
today += (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31);
break;
case 9:
today += (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30);
break;
case 10:
today += (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31);
break;
case 11:
today += (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30);
break;
default:printf("error\n");
}
today = day + today;
int k= 365 - today;
int w = today + 365 * (year - 2013)+92;
if( year % 4 == 0 && year % 100 != 0year%400==0)today=today+1;
else today=today+0;
printf("%d年%d月%d日是该年的第%d天,距离今年结束还有%d天,是我们相恋第%d天。\n", year, month, day, today,k,w);
return 0;
}
一个计算我和我老婆相恋时间的程序。
热门评论
冰冷的代码与狗粮在我脸上胡乱拍打着
猝不及防吃口狗粮,,,,,请爱护小动物
用swich不如用数组