日期对称程序

今天是世界完全对称日,2011年11月2日(20111102).这个日子将是现今人们所能经历的最后一个“世界完全对称日”。这个比百年等一回的光棍节更值得纪念有木有!


网上又在流转一些特别的节日,有点夸大的意思,无聊用程序验证一下:

package ob;

public class DateSymmetry {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String[] s1 = new String[100];
		String[] s2 = new String[100];
		char[] temp = null;
		for(int i=0; i<100; i++) {
			s1[i] = (2000 + i) + "";
			temp = s1[i].toCharArray();
			String month = "" + temp[temp.length-1] + temp[temp.length-2];
			String day = "" + temp[temp.length-3] + temp[temp.length-4];
			int m = Integer.parseInt(month);
			int d = Integer.parseInt(day);
			if(m > 0 && m < 13 && d > 0 && d < 31) {
				String str = month + day;
				s2[i] = s1[i] + str;
			}
		}
		for (String str : s2) {
			if(str != null) {
				System.out.println(str);
			}
		}
	}
}

输出结果:

20011002
20100102
20111102
20200202
20211202
20300302
20400402
20500502
20600602
20700702
20800802
20900902



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章