public static void main(String[] args) {
int dayofyears=0;
int dayofmonth=0;
Scanner input=new Scanner(System.in);
System.out.println("请输入年份:");
int year=input.nextInt();
System.out.println("请输入月份:");
int month=input.nextInt();
for(int n=0001;n<year;n++){
if(((n%4==0)&&(n%100!=0))||(n%400==0)){
dayofyears=dayofyears+366;
}
else{
dayofyears=dayofyears+365;
}
}
for(int bigmonth=1;bigmonth<=month;bigmonth++){
if(bigmonth==1||bigmonth==3||bigmonth==5||bigmonth==7||
bigmonth==8||bigmonth==10||bigmonth==12){
dayofmonth=31;
}
else if(bigmonth==2){
if(((year%4==0)&&(year%100!=0))||(year%400==0)){
dayofmonth=29;
}
else{
dayofmonth=28;
}
}
else{
dayofmonth=30;
}
if(bigmonth<month){
dayofyears=dayofyears+dayofmonth;
}
}
System.out.println("星期一\t星期二\t星期三\t星期四\t星期五\t"
+ "星期六\t星期天");
int temp=(dayofyears%7);
for(int m=0;m<temp;m++){
System.out.println("\t");
}
for(int w=1;w<=dayofmonth;w++){
System.out.println(w+"\t");
if((dayofyears+w)%7==0){
System.out.println();
}
}
}
}
请大神告诉我为什么运行的时候,那些数字不是横向的,而是纵向显示
无趣的天空
相关分类