题目
public class Main {
static int[] date = new int[] {0,31,28,31,30,31,30,31,31,30,31,30,31};
public static boolean res(StringBuffer s) {
String ss = s.toString();
//yyrr
for(int i=0;i<2;i++) {
int x = Integer.parseInt(s.charAt(i)+"");
int y = Integer.parseInt(s.charAt(i+1)+"");
int z = Integer.parseInt(s.charAt(i+2)+"");
if((y-x == 1) && (z-y == 1)) {
return true;
}
}
return false;
}
public static void main(String[] args) {
//2022xxyy
//2022不是闰年
StringBuffer s = new StringBuffer();
int sum = 0;
for(int i=1;i<=12;i++) {
if(i<10) {
s.append("0"+i);
}else {
s.append(i);
}
for(int j=1;j<=date[i];j++) {
if(j<10) {
s.append("0"+j);
}else {
s.append(j);
}
//组成四位yyrr
if(res(s)) {
sum++;
}
s.delete(2,s.length());
}
s.delete(0,s.length());
}
System.out.println(sum);
}
}