|

楼主 |
发表于 2022-4-21 11:03:45
|
显示全部楼层
这是新的问题....
下面是代码
- #include <stdio.h>
- int main() {
- int a, b, c;
- int d, e, f;
- int h = 0;
- printf("请输入你的生日(如果1988-05-20):");
- scanf_s("%d-%d-%d", &a, &b, &c);
- printf("请输入今年的日期(如2016-03-28):");
- scanf_s("%d-%d-%d", &d, &e, &f);
- for (; a <= d; a++) {
- int g[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- g[1] = (a % 400 == 0 || (a % 4 == 0 & a % 100 == 0))? 29 : 28;
- for (; b <= 12; b++) {
- for (; c <= g[b - 1]; c++) {
- if (a == d && b == e && c == f) {
- goto result;
- }
- h++;
- }
- c = 1;
- }
- b = 1;
- }
- result:
- printf("你在这个世界上总共生存了%d天\n", h);
- return 0;
- }
复制代码 |
|