Scanner xq=new Scanner(System.in); System.out.print("请输入年:"); int year=xq.nextInt(); System.out.println("---------------------"); System.out.print("请输入月:"); int mon=xq.nextInt(); System.out.println("---------------------"); System.out.print("请输入日:"); int day=xq.nextInt(); System.out.println("---------------------"); int allday; //存储全部天数 allday=year*365; //把年换算成天 allday=allday+(year/4);//加上闰年多出来的天 if(mon==2){ //以下是把月换算成天 allday=allday+31; } else if(mon==3){ allday=allday+59; } else if(mon==4){ allday=allday+90; } else if(mon==5){ allday=allday+120; } else if(mon==6){ allday=allday+151; } else if(mon==7){ allday=allday+181; } else if(mon==8){ allday=allday+212; } else if(mon==9){ allday=allday+243; } else if(mon==10){ allday=allday+273; } else if(mon==11){ allday=allday+304; } else if(mon==12){ allday=allday+334; } allday=allday+day; //直接加上刚才输入的天数 int xx1; //存储是星期几 xx1=(allday%7)-2; if(xx1==-2){ xx1=5; } else if(xx1==-1){ xx1=6; } else if(xx1==0){ xx1=7; } System.out.println("星期"+xx1);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)