码迷,mamicode.com
首页 > 其他好文 > 详细

acm2005

时间:2015-02-13 11:40:03      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:acm   java   

/**
 * 第几天
 */
import java.util.*;


public class acm2005 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String date = in.next();
int y = 0;
int m = 0;
int d = 0;
String str[] = new String[3];
str = date.split("/");
for (int i = 0; i < str.length; i++) {
if (i == 0) {
y = Integer.parseInt(str[i]);
} else if (i == 1) {
m = Integer.parseInt(str[i]);
} else if (i == 2) {
d = Integer.parseInt(str[i]);
}
}
int sum = 0;
for (int month = 1; month < m; month++) {
if (month == 2) {
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
sum += 29;
else
sum += 28;
} else {
if (month == 4 || month == 6 || month == 8 || month == 11)
sum += 30;
else
sum += 31;
}


}
sum += d;
System.out.println(sum);
}
}
}

acm2005

标签:acm   java   

原文地址:http://blog.csdn.net/a736933735/article/details/43792519

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!