哪位C++大神能解释下这个错误吗?提交到OJ系统就是显示不对?QAQ
#include<iostream>usingnamespacestd;intleap(inta){if(a%4==0&&a%100!=0||a%400==0)retur...
#include<iostream>using namespace std;int leap(int a) {if (a % 4 == 0 && a % 100 != 0 || a % 400 == 0)return 1;elsereturn 0;}int number(int year, int m, int d){int sum = 0, i, a[12] ={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int b[12] ={31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if (leap(year) == 1)for (i = 0; i < m - 1; i++)sum += b[i];elsefor (i = 0; i < m - 1; i++)sum += a[i];sum += d;return sum;}int main(){int year, month, day, n,k=0;while(scanf("%d%d%d", &year, &month, &day)==3){ n = number(year, month, day);printf("Case %d: %02d/%02d/%d, %d\n",++k,month,day,year,n);}return 0;}
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询