C++习题 给出年、月、日,计算该日是该年的第几天?(高分求)

来源:百度知道 编辑:UC知道 时间:2024/06/28 13:03:38
(高分求)
1、给出年、月、日,计算该日是该年的第几天?(要算闰年)

2、求和 1 - 1/2 +1/3 - 1/4 + 1/5...+ 1/99 - 1/100 。

3、实现52张扑克牌的洗牌, 4个玩家,输出一个人手里拿的牌面。
随机数的获取方法rand()
srand((unsigned)time(NULL));
srand( (unsigned)time( NULL ) );

本人新手,请高人指教!!!!(高分求)

一共3题,,,用C++写,不是C
要这样形势的,cout<<""<<endl;

不要这样的
printf("输入年月日\n");
scanf("%d%d%d",&year,&month,&day);
printf("%d\n",and(year,month,day));

倒计时明天中午12点过后回答的分数无效!!!!所以,急急急~~万分感谢!
- -##第一题是算是该年的第几天,不是算的是星期几!!!
一楼回答的是星期几啊,,~~~~~~~~~~~~~~~~~~~~~

1。

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
cout << "请输入年月日(YYYY-MM-DD):";
char s[11] = {'\0'},year[5] = {'\0'},month[3] = {'\0'},day[3] = {'\0'};
int y,m,d,sum = 0;
cin >> s;
int size = strlen(s);
for(int it = 0,temp = 0; it < size; it++,temp++)
{
if(s[it] != '-')
{
year[temp] = s[it];
continue;
}
else
break;
}
it++;
temp = 0;
for(; it < size; it++,temp++)
{
if(s[it] != '-')
{
month[temp] = s[it];
continue;
}
else
break;
}
it++;
temp = 0;
for(; it < size; it++,temp++)
{
day[temp] = s[it];
}
y = atoi(year);
m = atoi(month);
d = atoi(day);