杭电2005为什么我的程序通不过?
#include<stdio.h>#include<math.h>#defineisLeap(year)(year%4==0&&(year%100!=0||year%40...
#include <stdio.h>
#include <math.h>
#define isLeap(year) (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
int main(void){
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int y, m, d, sum, i;
while (scanf("%d/%d/%d", &y, &m, &d) != EOF)
{
for (sum = 0, i = 0; i < m; i ++)
sum += month[i];
if(isLeap(y) != 0)
sum ++;
sum += d;
printf("%d\n", sum);
}
return 0;
} 展开
#include <math.h>
#define isLeap(year) (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
int main(void){
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int y, m, d, sum, i;
while (scanf("%d/%d/%d", &y, &m, &d) != EOF)
{
for (sum = 0, i = 0; i < m; i ++)
sum += month[i];
if(isLeap(y) != 0)
sum ++;
sum += d;
printf("%d\n", sum);
}
return 0;
} 展开
1个回答
展开全部
#include <stdio.h>
#include <math.h>
#define isLeap(year) (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
int main(void){
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int y, m, d, sum, i;
while (scanf("%d/%d/%d", &y, &m, &d) != EOF)
{
for (sum = 0, i = 0; i < m; i ++)
sum += month[i];
if(m>2 && isLeap(y) != 0) // month should be larger than 2
sum ++;
sum += d;
printf("%d\n", sum);
}
return 0;
}
#include <math.h>
#define isLeap(year) (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
int main(void){
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int y, m, d, sum, i;
while (scanf("%d/%d/%d", &y, &m, &d) != EOF)
{
for (sum = 0, i = 0; i < m; i ++)
sum += month[i];
if(m>2 && isLeap(y) != 0) // month should be larger than 2
sum ++;
sum += d;
printf("%d\n", sum);
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询