九度OJ 1070 今年的第幾天?(類比),oj1070

來源:互聯網
上載者:User

九度OJ 1070 今年的第幾天?(類比),oj1070

題目1070:今年的第幾天?

時間限制:1 秒

記憶體限制:32 兆

特殊判題:否

提交:3491

解決:1936

題目描述:

輸入年、月、日,計算該天是本年的第幾天。

輸入:

包括三個整數年(1<=Y<=3000)、月(1<=M<=12)、日(1<=D<=31)。

輸出:
輸入可能有多組測試資料,對於每一組測試資料,輸出一個整數,代表Input中的年、月、日對應本年的第幾天。
範例輸入:
1990 9 202000 5 1
範例輸出:
263122
#include<stdio.h>int month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};int isLeapYear(int Y){    if(Y%4==0&&Y%100!=0||Y%400==0)        return 1;    else return 0;}int  Y,M,D;void solve(){    int sum=0;    for(int i=1;i<=M-1;++i){        sum+=month[i];    }    sum+=D;    printf("%d\n",sum);}int main(int argc, char *argv[]){   // freopen("1070.in", "r", stdin);    while(~scanf("%d%d%d",&Y,&M,&D))    {        if(isLeapYear(Y)){            month[2]+=1;            solve();            month[2]-=1;        }        else            solve();     }    return 0;} /**************************************************************    Problem: 1070    User: kirchhoff    Language: C    Result: Accepted    Time:10 ms    Memory:912 kb****************************************************************/


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.