这是很简单的思路
#include <stdio.h> int main() { int i = 2008,sum=0; int m = 8; int d = 8; switch(m-1){ case 12: sum+=31; case 11 : sum+=30; case 10: sum+=31; case 9: sum+=30; case 8: sum+=31; case 7: sum+=31; case 6: sum+=30; case 5: sum+=31; case 4: sum+=30; case 3: sum+=31; case 2: if(i%4==0&&i%100!=0||i%400==0)sum+=29; else sum+=28; case 1:sum+=31;break; } printf("%d年%d月%d日是该年的第%d天,",i,m,d,sum+d); return 0; }