题目
有关日历计算,
要求输入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的
提问时间:2021-02-27
答案
以下是用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
#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
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1人类活动排放的CO2增多为什么会导致大气逆辐射增强
- 2物理中的比热容是什么意思?
- 3某公司生产的洗衣机每台售价1500元,单位变动成本900元,年固定成本1200万元,预定目标利润1000万元
- 4亚油酸分子式是什么
- 5Next Sunday (英译汉) the way to...(英译汉)
- 6普通话阳声字中,不送气的塞音、塞擦音声母字大都来自古入声,这是为什么?
- 7英语句子 Do the following survey
- 8集思广益,各抒己见,独出心裁造句(要连在一起的)急
- 9若sin(π+α)+sin(-α)=-m,则sin(3π+a)+2sin(2π-a)的值为?
- 10(小学五年级用字母表示数的学习时)为什么当a=11时,a+30=11+30=41为什么不用写单位呢
热门考点
- 1有一块长方形,长204米,宽108米.在这块地的四周植树,要使相邻的两颗树之间的距离相等,而且四角各植...
- 2已知多项式(n+2)x二次方ym-1次方+xy二次方-3x二次方-6是关于xy的六次多项式,则mn应满足的条件是
- 3除了钙、铁、碘以外,人体还需要哪些无机盐?
- 4墙上钉着用一根彩绳围成的梯形形状的饰物,如右图实线所示.小颖将梯形下底的钉子去掉,并将这条彩绳钉成一个长方形,如图虚线所示.小颖所钉长方形的长、宽各为多少厘米?
- 5《最后一课》对小弗郎士的人物描写的赏析
- 6新疆开始隶属中央政府管辖,成为我国的一部分,开始于何时,请举出史实,答案是西汉,史实是什么
- 7困倦无力,孜孜不倦,诲人不倦的倦意思相同吗 百度知道
- 875*40=3000,150*40=6000,75*200=15000,25*40=1000发现什么规律?
- 9积分.类似sin2x/cosx .
- 10英文今天星期几有几种说法?英文今天几号有几种说法?