zoukankan      html  css  js  c++  java
  • 杭电ACM2005--第几天?

    第几天?

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 210255    Accepted Submission(s): 73448


    Problem Description
    给定一个日期,输出这个日期是该年的第几天。
     
    Input
    输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。
     
    Output
    对于每组输入数据,输出一行,表示该日期是该年的第几天。
     
    Sample Input
    1985/1/20 2006/3/12
     
    Sample Output
    20 71
     
    年月日题其中之一,需要掌握
    月份的天数
    31,28,31,30,31,30,31,31,30,31,30,31
    闰年的判断 
      能被400整除 或者 能被4整除不能被100整除的年份称为闰年
     1 #include<stdio.h>
     2 
     3 int main()
     4 {
     5     int a,b,c,i,sum;
     6     while(~scanf("%d/%d/%d",&a,&b,&c))
     7     {
     8         int m[12]={31,28,31,30,31,30,31,31,30,31,30,31},sum=0;
     9         if((a%4==0&&a%100!=0)||a%400==0)m[1]=29;
    10         for(i=0;i<b-1;i++)
    11             sum+=m[i];
    12         sum+=c;
    13         printf("%d
    ",sum);
    14     }
    15     return 0;
    16 }
  • 相关阅读:
    ubuntu常用快捷键,不断更新中~
    C语言模拟漏斗
    浅谈webCam
    1001. A+B Format
    点、边、面——欧拉公式
    果园里的树
    生产计划
    Stanford Machine Learning 学习 2016/7/4
    paper reading
    paper reading in this week
  • 原文地址:https://www.cnblogs.com/lightice/p/10261100.html
Copyright © 2011-2022 走看看