第十六周-计算该日在本年中是第几天
2016-12-20 17:02
190 查看
#include <stdio.h> #include <stdlib.h> typedef struct { int year; int month; int day; } y_m_d; int main() { y_m_d date; int days(y_m_d); //y_m_d是自定义的类型 int day_sum; scanf("%d%d%d",&date.year,&date.month,&date.day); day_sum=days(date); printf("%d\n",day_sum); return 0; } int days(y_m_d date) { int i,count=date.day; for(i=1; i<date.month; ++i) { switch(i) { case 2: count+=((date.year%4==0&&date.year%100!=0)||date.year%400==0)?29:28; break; case 4: case 6: case 9: case 11: count+=30; break; default: count+=31; break; } } return count; }
相关文章推荐
- 第十六周 计算该日在本年中是第几天
- 第十六周OJ——计算该日在本年中是第几天
- 第十六周-OJ-A计算该日在本年中是第几天
- 第十六周 OJ<1>---计算该日在本年中是第几天
- 第十六周 计算该日在本年中是第几天
- 第十六周oj题目计算该日是本年的第几天
- 第十六周OJ(1)计算该日在本年中是第几天
- 第十六周 OJ 计算该天是本年中的第几天
- Problem A: C语言习题 计算该日在本年中是第几天
- 结构体计算该日在本年中是第几天
- 了解switch的选择器的特点并用switch计算指定的年月日是本年的第几天
- 问题 A: C语言习题 计算该日在本年中是第几天
- 结构体计算该日在本年中是第几天
- 计算该日在本年中是第几天?注意瑞年问题。(分别用结构体变量和函数实现)
- Problem A: C语言习题 计算该日在本年中是第几天
- 计算该日是本年的第几天
- 第16周 oj Problem A: C语言习题 计算该日在本年中是第几天
- [YTU]_2428(C语言习题 计算该日在本年中是第几天)
- C/C++复习:计算该日在本年中是第几天(结构体,优化版)
- 定义一个结构体变量(包括年、月、日),编写程序,要求输入年月日,程序能够计算并输出改日是本年中的第几天。注意闰年问题。(数组)