Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
牛人帮忙我也是对着万年历看了好久 不知所错何处 #include<iostream> #include<iomanip> using namespace std; const int NORM = 365, LEAP = 366; struct SDate{ int iyear, imon, iday; char *cpweek; }; void main() { SDate Ddate; int idays, itemp; bool isLeap; int iamon[2][13] = {{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; char *cpaweek[7] = {"Saturday", "Sunday", "Monday","Tuesday", "Wednesday", "Thursday", "Friday"}; scanf("%d", &idays); while(idays != -1){ Ddate.iyear = 2000; isLeap = true; itemp = idays + 1; while(1){ //deal with year if(itemp > LEAP){ itemp -= LEAP; Ddate.iyear++; isLeap = false; } else break; for(int i = 0; i < 3 && itemp > NORM; i ++) { itemp -= NORM; Ddate.iyear++; } if(i == 3) isLeap = true; else break; } for(Ddate.imon = 1; itemp > iamon[isLeap][Ddate.imon]; Ddate.imon++) itemp -= iamon[isLeap][Ddate.imon]; Ddate.iday = itemp; Ddate.cpweek = cpaweek[idays % 7]; printf("%d-%02d-%02d %s", Ddate.iyear, Ddate.imon , Ddate.iday, Ddate.cpweek); scanf("%d", &idays); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator