C語言實驗——數日子

來源:互聯網
上載者:User
Problem Description 光陰似箭,日月如梭,大學的時間真是寶貴,要抓緊時間AC^_^。你知道今天是這一年第幾天嗎,掐指一算還是要算好久,呵呵還是讓電腦來做吧。這裡的問題就是讓你來寫一個程式,輸入某年某月某日,判斷這一天是這一年的第幾天。 Input 輸入資料有多組,第一行是資料的組數n,下面n行是n組資料,每組資料由3個正整數組成,分別為年、月、日,我們保證每組資料都是有效日期。 Output 輸出所輸入的日期是這一年的第幾天。 Example Input
22009 1 12008 1 3
Example Output
1

3

#include<stdio.h>   int main()   {       int n, a, b, a1, b1 , c1, f[100]={0}, y[12];       y[0]=31;       y[2]=31;       y[3]=30;       y[4]=31;       y[5]=30;       y[6]=31;       y[7]=31;       y[8]=30;       y[9]=31;       y[10]=30;       y[11]=31;       while(scanf("%d", &n)!=EOF) {     for(a=0;a<n;a++)       {           scanf("%d %d %d", &a1, &b1, &c1);           if((a1%4==0&&a1%100!=0)||(a1%400==0))           {               y[1]=29;           }           else y[1]=28;           for(b=0;b<b1-1;b++)           {               f[a]=f[a]+y[b];           }           f[a]=f[a]+c1;       }       for(a=0;a<n;a++)       {           printf("%d\n", f[a]);       } }     return 0;   }  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.