LanQiaoTestCodes/跑步锻炼.java

47 lines
972 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package LanQiaoOJ;
/*
* 小蓝每天都锻炼身体。
正常情况下小蓝每天跑1干米。如果某天是周一或者月初(1日)为了激励自己小蓝要跑2干米。如果同时是周一
或月初小蓝也是跑2干米。小蓝跑步已经坚持了很长时间从2000年1月1日周六(含)到2020年10月1日周四含)。
请问这段时间小蓝总共跑步多少干米?*/
public class 跑步锻炼 {
//每月天数
static int []w= {0,31,28,31,30,31,30,31,31,30,31,30,31};
//定义年月日
//t=1表示星期一t=0表示星期天
static int y=2000,m=1,d=1,t=6;
static int count=0;
public static void main(String[] args) {
// TODO Auto-generated method stub
while(y!=2020||m!=10||d!=1){
if(y%400==0||y/400==0&&y/100!=0)
w[2]=29;
else
w[2]=28;
if(d==1||t==1) {
count+=2;
}
else {
count++;
}
d++;
t++;
t%=7;
if(d>w[m]) {
m++;
d=1;
}
if(m>12) {
y++;
m=1;
}
if(y==2020&&m==10&&d==1) {
count+=2;
}
}
System.out.print(count);
}
}