int main () { char* month[] = { "January", "Feburary", "March", "Appril", "May", "June", "July", "August", "September","Octorbor","November","December" }; int i,p,y, m[] = {1,-2,1,0,1,0,1,1,0,1,0,1}; cout << "Enter year: "; cin >> y; i = y - 1; p = (y + i/4 - i/100 + i/400) % 7; //算當年1月1日的位置 if (y%4==0 && y%100 || y%400==0) m[1] = -1; for (y=0; y<12; y++) { cout << "\n------- "<<month[y]<<" -------" << "\n Su Mo Tu We Th Fr Sa\n"; for (i=p; i--;) cout <<" "; for (i=1; i<=m[y]+30; i++) printf (" %2d%s", i, (p+i)%7? "":"\n"); p = (p + m[y] + 30) % 7; } }
2009年10月31日 星期六
萬年曆
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言