输出日历
Calendar 2006-12--------------------------Su Mo Tu We Th Fr Sa-------------------------- 1 2 3 4 5 6 7 8 910 11 12 13 14 15 1617 18 19 20 21 22 2324 25 26 27 28 29 3031--------------------------
code:
import java.util.*;public class Main { public static void fun() { System.out.print("Calendar 2006-12"+"\n"); System.out.print("--------------------------"+"\n"); System.out.print("Su Mo Tu We Th Fr Sa"+"\n"); System.out.print("--------------------------"+"\n"); int temp = 0; for(int i=1;i<=31;i++) { if(i<2) { System.out.print(" "); System.out.print(i+" "+(i+1)+"\n"); } if(i>2&&i<10) { System.out.print(" "+i+" "); if(i==9) { System.out.print("\n"); } } if(i>=10&&i<17) { System.out.print(i+" "); if(i==16) { System.out.print("\n"); } } if(i>=17&&i<24) { System.out.print(i+" "); if(i==23) { System.out.print("\n"); } } if(i>=24&&i<31) { System.out.print(i+" "); if(i==30) { System.out.print("\n"); } } if(i==31) { System.out.print(i); } } System.out.print("\n"+"--------------------------"+"\n"); } public static void main(String[] args) { fun(); } }