• 第几天?


     
    Problem Description
    给定一个日期,输出这个日期是该年的第几天。
     
    Input
    输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。
     
    Output
    对于每组输入数据,输出一行,表示该日期是该年的第几天。
     
    Sample Input
    1985/1/20
    2006/3/12
     
    Sample Output
    20
    71
     
           
     1 #include<iostream>
     2 #include<cmath>
     3 #include<cstdio>
     4 #include<iomanip>
     5 using namespace std;
     6 bool judge(int year)
     7 {
     8     if((year%4==0&&year%100!=0)||year%400==0) return 1;//条件判断leapyear
     9     else return 0;
    10 }
    11 struct node
    12 {
    13     int ans[13];
    14     node()
    15     {
    16         ans[0]=0;ans[1]=31;ans[2]=28;ans[3]=31;ans[4]=30;ans[5]=31;ans[6]=30;ans[7]=31;ans[8]=31;ans[9]=30;ans[10]=31;ans[11]=30;ans[12]=31;
    17     }
    18     int cal(int x)
    19     {
    20         int sum=0;
    21         for(int i=1;i<x;++i)
    22             sum+=ans[i];
    23         return sum;
    24     }
    25 };
    26 
    27 int main()
    28 {
    29     int a,b,c;
    30     while(scanf("%d/%d/%d",&a,&b,&c)==3)
    31     {
    32         node s;
    33         if(judge(a))  s.ans[2]++;
    34         cout<<s.cal(b)+c<<endl;
    35     }
    36 }
    View Code
  • 相关阅读:
    EF--CodeFirst
    一个很吊的文章---框架
    EF的代码优先设计
    MVC3--View层
    asp.net返回值当文件下载问题
    MVC源码
    编译原理
    TPatch动态补丁系统(iOS)
    浅析分布式系统
    如何在腾讯云快速构建一个Wordpress个人站点
  • 原文地址:https://www.cnblogs.com/Auroras/p/10794876.html
Copyright © 2020-2023  润新知