给出年,月,日,编写函数计算该日是该年的第几天。(vc++6.0,编写函数,函数调用)
答案:1 悬赏:10 手机版
解决时间 2021-11-27 12:43
- 提问者网友:沉默菋噵
- 2021-11-26 13:05
给出年,月,日,编写函数计算该日是该年的第几天。(vc++6.0,编写函数,函数调用)
最佳答案
- 五星知识达人网友:北方的南先生
- 2021-11-26 14:31
#include "string.h"
#include "stdio.h"
#define N 2
struct student
{
} today()
{
int a, b, c, d, e, f;
printf("请输入年月日:\n");
scanf("%d %d %d", &a, &b, &c);
f = a;
d = e = 0;
a = (a % 4 == 0) ? 1 : 0;
while (0 < b - d)
{
switch (d)
{
case 0:
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
e += 31;
break;
case 2:
e = e + 28 + a;
break;
case 4:
case 6:
case 9:
case 11:
e += 30;
break;
}
d += 1;
}
printf("%d年之第%d天,离来年%d天!\n", f, e + c, 365 - e - c);
}
TiDay()
{
printf("\nTiDay\n");
}
main()
{
int a = 0, b, c, d, e, f, g;
today();
TiDay();
today();
}追答
辛勤之作,望采纳!
#include "stdio.h"
#define N 2
struct student
{
} today()
{
int a, b, c, d, e, f;
printf("请输入年月日:\n");
scanf("%d %d %d", &a, &b, &c);
f = a;
d = e = 0;
a = (a % 4 == 0) ? 1 : 0;
while (0 < b - d)
{
switch (d)
{
case 0:
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
e += 31;
break;
case 2:
e = e + 28 + a;
break;
case 4:
case 6:
case 9:
case 11:
e += 30;
break;
}
d += 1;
}
printf("%d年之第%d天,离来年%d天!\n", f, e + c, 365 - e - c);
}
TiDay()
{
printf("\nTiDay\n");
}
main()
{
int a = 0, b, c, d, e, f, g;
today();
TiDay();
today();
}追答
辛勤之作,望采纳!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯