标签:查询 blog efault ati can system ++ import 星期六
import java.util.Scanner; class zuoye_2 { public static int day (int i) { int r1 = 0; int r2 = 0; for (int j=1900;j<i ;j++ ){ if (j%4==0&&j%100!=0||j%400==0){ r1++; } else{ r2++; } } return (r1*366+r2*365); } public static int ri(int a,int c){ int b = 0; if (c%4==0&&c%100!=0||c%400==0){ switch(a){ case 1 : b = 0; break; case 2 : b=31; break; case 3 : b = 60; break; case 4 : b = 91; break; case 5 : b = 121; break; case 6 : b = 152; break; case 7 : b = 182; break; case 8 : b = 213; break; case 9 : b =244 ; break; case 10 : b = 274; break; case 11 : b =305; break; case 12 : b = 335; } } else{ switch(a){ case 1 : b = 0; break; case 2 : b=31; break; case 3 : b = 59; break; case 4 : b = 90; break; case 5 : b = 120; break; case 6 : b = 151; break; case 7 : b = 181; break; case 8 : b = 212; break; case 9 : b =243 ; break; case 10 : b = 273; break; case 11 : b =304; break; case 12 : b = 334; } } return b; } public static void shuChu(int i,int j,int z) { int a1 =0; int a3 = i; for(int a = 0;a<i ;a++) { System.out.print(" "+"\t"); } if (z%4==0&&z%100!=0||z%400==0){ switch(j) { default: a1=31; break; case 2: a1=29; break; case 4: case 6: case 9: case 11: a1=30; } } else{ switch(j){ default: a1=31; break; case 2: a1=28; break; case 4: case 6: case 9: case 11: a1=30; } } for(int a2=1;a2<=a1;a2++) { System.out.print((a2)+"\t"); a3++; if(a3%7==0){ System.out.println(); } } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("请输入想要查询的年份"); int y= sc.nextInt(); System.out.println("请输入想要查询的月份"); int m1=sc.nextInt(); System.out.println("星期一"+"\t"+"星期二"+"\t"+"星期三"+"\t"+"星期四"+"\t"+"星期五"+"\t"+"星期六"+"\t"+"星期日"+"\t"); int d2=day(y); int d1=ri(m1,y); int d=0; d=d1+d2; int yu = d%7; shuChu(yu,m1,y); System.out.println(d); } }
标签:查询 blog efault ati can system ++ import 星期六
原文地址:http://www.cnblogs.com/zhydeblog/p/7183305.html