有关日历计算,要求输入n,输出从2000.1.1开始往后n天的那一天的年月日星期.Given the number of
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/09 09:14:26
有关日历计算,
要求输入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的
以下是用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
有关日历计算,要求输入n,输出从2000.1.1开始往后n天的那一天的年月日星期.Given the number of
c语言 计算m的n次方 要求输入m、n 输出m的n次方
设计一个窗体,要求输入一个正整数N,计算并输出N的阶乘.VB的
怎样用java编写一个程序,从键盘上输入数n,计算并输出1!+2!...+n!的结果
c语言:从键盘任意输入一个整数n,编程计算并输出1-n之间的所有素数之和
输入一个正整数n,计算1+1/2!+1/3!……1/n!的和并输出.要求将计算阶乘的运算定义
编写一个C#控制台应用程序,对于输入的正整数n,计算1!+2!+3!+…+n!的值并输出结果!要求完整的哈!
从键盘上输入任意一个整数n,计算1到n的和.输入 从键盘输入任意整数n.输出1到n的和.用c语言
题目是这个:输入正整数n,在主函数中输出1!+2!+3!+...的值,要求将计算阶乘的运算写成函数JC(n).
对运行中输入的x,计算级数:1+ x – x2/2!+ x3/3!- …(-1) n+1*xn/n!.要求输出精度为10
按如图的程序计算,若开始输入的n的值是2,则最后输出的结果是()
按如图所示的程序计算,若开始输入的n值为4,则最后输出的数是___