首页 > 其他 > 详细

acm2005

时间:2015-02-13 11:37:41      阅读:196      评论:0      收藏:0      [点我收藏+]
/**
 * 第几天
 */
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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!