用C程式設計計算某日期是一年中第幾天

2021-04-12 22:48:28 字數 904 閱讀 5515

/* 1.輸入年月日,編寫程式計算所輸日期是當年的第幾天 */

/* 2.已知列車隔日發車,且1/1/2006不發車(無ticket),如果所輸入資料在此日期之後,則輸出有沒有車票,否則僅輸出上一步結果。*/

/* month/date/year is which day of the year */

/* is there a ticket today(2006.01.01--yeath!)?? */

#include

int year,month,date;

void input()

/* read input number and judge is it legal*/

}int isleapyear(int year)       

/* is the year a leapyear */

int days(int year,int month,int date)

/* calculate the days since jan,1,year.(you input the "year") */

if(isleapyear(year)&&month>2) day+=1;

return(day);

}int main(void)

printf("%d/%d/%d  day:%d/n",month,date,year,n);

puts("press anykey to quit!");

getch();

return 0;

}2.文章全部為原創,過程中可能有些文章參考了某些文章的思路,但本人宗旨和目標只是:a.不如我之人可以向我學習b.希望高手可以對我指點一二,以求做到最好;c.資源共享;別無其他。

3.tc2.0下通過。當然,解法很多,如果哪位找到更好方法的話,如若可以分享我將很榮幸。

C 計算當前日期是一年中的第幾周

方法一 private int weekofyear string date else 方法二 system.globalization.gregoriancalendar gc new system.globalization.gregoriancalendar int weekofyear gc...

c 計算一年中的第幾天

int y,d,m int m1 31,m2 28,m3 31,m4 30,m5 31,m6 30,m7 31,m8 31,m9 30,m10 31,m11 30,m12 31 console.writeline 請輸入年份 y convert.toint32 console.readline if...

輸入日期判斷這天是一年中第幾天

判斷這天是一年中第幾天 nonleap 0 31,28 31,30 31,30 31,31 30,31 30,31 leap 0 31,29 31,30 31,30 31,31 30,31 30,31 sum 0 date input 請輸入想要查詢的年月日,格式如 x xx xx n date d...