以下是用C++寫的
#include
struct InNum
{
int num;
InNum *next;
};
void main()
{
int year=2000,day=1,mouth=1,dayTemp=0,week0=6,week;
InNum *head,*last,*p;
head=new InNum;
head->next=NULL;
last=head;
p=new InNum;
cin>>p->num;
p->next=NULL;
last->next=p;
last=last->next;
while(p->num>0)
{
p=new InNum;
cin>>p->num;
p->next=NULL;
last->next=p;
last=last->next;
}
p=head->next;
while(p->num>=0)
{
p->num--;
while(p->num>=365)
{
year++;
p->num-=365;
}
dayTemp=p->num;
while(p!=NULL && p->num>28)
{
if(2==mouth && 0==year%4 && p->num>=29)
{
mouth++;
p->num-=29;
}
else if(2==mouth && p->num>=28)
{
mouth++;
p->num-=28;
}
else if(mouthnum>mouth%2+30)
{
p->num-=(mouth%2+30);
mouth++;
}
else if(mouth>=9 && p->num>(mouth+1)%2+30)
{
p->num-=((mouth+1)%2+30);
mouth++;
}
else
break;
}
day = p->num;
week = (dayTemp + year-2001+1)%7;
cout
有關(guān)日歷計算,
有關(guān)日歷計算,
要求輸入n,輸出從2000.1.1開始往后n天的那一天的年月日星期.
Given the number of days that have elapsed since January 1,2000 A.D,your mission is to find the date and the day of the week.
Input
The input consists of lines each containing a positive integer,which is the number of days that have elapsed since January 1,2000 A.D.The last line contains an integer -1,which should not be processed.You may assume that the resulting date won't be after the year 9999.
Output
For each test case,output one line containing the date and the day of the week in the format of "YYYY-MM-DD DayOfWeek",where "DayOfWeek" must be one of "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday" and "Saturday".
Sample Input
1730
1740
1750
1751
-1
Sample Output
2004-09-26 Sunday
2004-10-06 Wednesday
2004-10-16 Saturday
2004-10-17 Sunday
要c的
要求輸入n,輸出從2000.1.1開始往后n天的那一天的年月日星期.
Given the number of days that have elapsed since January 1,2000 A.D,your mission is to find the date and the day of the week.
Input
The input consists of lines each containing a positive integer,which is the number of days that have elapsed since January 1,2000 A.D.The last line contains an integer -1,which should not be processed.You may assume that the resulting date won't be after the year 9999.
Output
For each test case,output one line containing the date and the day of the week in the format of "YYYY-MM-DD DayOfWeek",where "DayOfWeek" must be one of "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday" and "Saturday".
Sample Input
1730
1740
1750
1751
-1
Sample Output
2004-09-26 Sunday
2004-10-06 Wednesday
2004-10-16 Saturday
2004-10-17 Sunday
要c的
其他人氣:121 ℃時間:2020-10-01 22:40:43
優(yōu)質(zhì)解答
我來回答
類似推薦
- 日歷是怎么算出來的?
- 中國的日歷是怎么算的!
- 特殊日歷計算
- 日歷周期的計算原則是什么?
- 根據(jù)第一頁日歷,計算后兩頁日歷上的日期各是星期幾
- 碳酸鹽與鹽酸反應(yīng)放出的氣體,所以與鹽酸反應(yīng)放出氣體的物質(zhì)一定是碳酸鹽.
- 2又84/23減去1又60/49怎么算?
- what is the freezing point of platinum?
- 翻譯句子 這有幾罐可樂.英文哦 急急急··········
- 一直關(guān)于x的方程a(x^2)+2x+1=0至少有一個負(fù)實數(shù)根,則實屬a的取值范圍 Aa
- 來幫我理解下這句話的意思
- 1加1加2分之1加1加2加3分之1加.加1加2加3加.加2000分之1 等于多少
猜你喜歡
- 1tell the truth 和 tell a lie的區(qū)別
- 2背英語單詞customs(海關(guān)) passport(護(hù)照) tourist(旅游者) employee(雇員) sales reps(推銷員)的秘訣
- 3什么叫圓的面積和周長?
- 4每天運(yùn)320噸,需要15天才能運(yùn)完.如果運(yùn)的天數(shù)減少到原來的80%,每天比原來多運(yùn)多少噸?
- 5小貓抓老鼠,翻譯成英語是怎么樣的呢?
- 6在物理實驗操作考查中,小雨抽測的實驗題目是“探究浮力的大小”.他的實驗操作步驟如圖所示,實驗過程如下
- 7當(dāng)我看到某人在下雨的時候沒有雨傘,我會和他一起用我的雨傘 英語翻譯
- 8在直角坐標(biāo)系xoy中,反比例函數(shù)y=m/x的圖像與一次函數(shù)y=kx+b的圖像交于點(diǎn)A(m,2)和C(-2,-3)
- 9get rid of的意思和throw away 更近還是和set free 更近?或give up(好像差很遠(yuǎn))
- 103pint?pints?oficecream
- 11We had ( )exam ,It was( )English exam
- 12如圖,一根繩子在圓柱體上從一端到另一端繞了5整圈,圓柱底面周長是6米,長為40米,則繩子長多少米?