标题:请教关于万年历的事情
只看楼主
l2480035288
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2013-3-15
结帖率:73.33%
已结贴  问题点数:11 回复次数:1 
请教关于万年历的事情
package 万年历;

import java.util.Scanner;

public class calendar {
   


    public static void main(String[] args) {
        int year,month,day=1,j,i;
        int[][] a;
        a=new int[5][7];
        @SuppressWarnings("resource")
        Scanner cin= new Scanner(System.in);
        year=cin.nextInt();
        month=cin.nextInt();
        if((year%4==0&&year%100!=0)||year%100==0)
            if(month==2)
            {
                for(i=0;i<5;i++)
                {
                    for(j=0;j<7;j++)
                        a[i][j]=day;
                        System.out.print(a[i][j]+"\t");
                        day++;
                        if(day>=28)
                        {
                            break;
                        }
                }
                System.out.println();
            }
    else
    {
        if(month==2)
        {
            for(i=0;i<5;i++)
                {
                    for(j=0;j<7;j++)
                    {
                        a[i][j]=day;
                        System.out.print(a[i][j]+"\t");
                        day++;
                        if(day>=29)
                        {
                            break;
                        }
                    }
                    System.out.println();
                }
            }
        }
        if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
        {
            for(i=0;i<5;i++)
                {
                    for(j=0;j<7;j++)
                    {
                        a[i][j]=day;
                        System.out.print(a[i][j]+"\t");
                        day++;
                        if(day>31)
                        {
                            break;
                        }
                    }
                    System.out.println();
                }
        }
        else if(month==4||month==6||month==9||month==11)
        {
            for(i=0;i<5;i++)
            {
                    for(j=0;j<7;j++)
                    {
                        a[i][j]=day;
                        System.out.print(a[i][j]+"\t");
                        day++;
                        if(day>30)
                        {
                            break;
                        }
                    }
                    System.out.println();
            }
        }
    }
}
            
        
        
        // TODO 自动生成的方法存根

   
这是我的程序,可是我不会把每月第一天放在星期几,应该怎么改进这个程序才会像正常的日历一样
搜索更多相关主题的帖子: 万年历 calendar package public import 
2013-09-22 22:53
java小蚂蚁
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:上海
等 级:贵宾
威 望:18
帖 子:558
专家分:2186
注 册:2013-7-2
得分:8 
可是我不会把每月第一天放在星期几
这句话什么意思?

学海无涯#¥%……&*(
2013-09-23 10:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-420927-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.163790 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved