• HDU_2005——今天是今年的第几天


    Problem Description
    给定一个日期,输出这个日期是该年的第几天。
     
    Input
    输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。
     
    Output
    对于每组输入数据,输出一行,表示该日期是该年的第几天。
     
    Sample Input
    1985/1/20 2006/3/12
     
    Sample Output
    20 71
     1 #include <cstdio>
     2 #include <cctype>
     3 const int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
     4 bool is_leapyear(int year)
     5 {
     6    if((year%4==0 && year%10!=0)||year%400==0)
     7       return true;
     8    return false;   
     9 }
    10 int main()
    11 {
    12    char str[15];
    13    while(~scanf("%s",str))
    14       {
    15          int a[3]={0},day=0;
    16          for(int i=0,j=0;str[i];i++)
    17             {
    18                if(isdigit(str[i]))
    19                   a[j]=a[j]*10+str[i]-'0';
    20                else
    21                   j++;     
    22             }
    23          for(int i=0;i<a[1]-1;i++)
    24             day=day+days[i];
    25          day=day+a[2];
    26          printf("%d\n",is_leapyear(a[0])?day+1:day);    
    27       }
    28    return 0;
    29 }
    ——现在的努力是为了小时候吹过的牛B!!
  • 相关阅读:
    BN
    框架中的DDP和buffer
    深度学习框架中的并行
    Transformer
    自监督表示学习Paper
    半监督学习paper阅读
    目标检测经典paper
    STM32_从SystemInit、__main到main() 已修正
    STM32启动代码分析及其汇编学习-ARM
    Rust 及其包管理Cargo的安装使用
  • 原文地址:https://www.cnblogs.com/pingge/p/3138061.html
Copyright © 2020-2023  润新知