张彦明ID:yanmingzi
251次访问,排名2万外好友2人,关注者2
学术交流是人生上最爽快的事
yanmingzi的文章
原创 8 篇
翻译 0 篇
转载 0 篇
评论 1 篇
最近评论
yanmingzi:生活在这种充满新技术的世界里太美了!
文章分类
收藏
    相册
    phtone
    ts229班望裕山庄春游
    java
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 万年历的编写收藏

    新一篇: java 的居中显示代码 | 旧一篇: 数据库

    =========================== 1 ==========================
    import javax.swing.*;
    import java.lang.*;


    public class Wanyear
    {
    public static void main(String[] args)
    {
    String input=JOptionPane.showInputDialog
    ("Please Enter the year");

    int year=Integer.parseInt(input);

    String input1=JOptionPane.showInputDialog
    ("Please Enter the Month");

    int m=Integer.parseInt(input1);


    String input2=JOptionPane.showInputDialog
    ("Please Enter the Day");

    int d=Integer.parseInt(input2);

     


    String Nyear=Integer.toString(year);

    String Sc=Nyear.substring(0,1);
    String Sy=Nyear.substring(2,3);

    int c=Integer.parseInt(Sc);
    int y=Integer.parseInt(Sy);

    if(m<3){
    year--;
    m+=12;}

    else
    c--;


    int w=(c/4)-(2*c)+y+(y/4)+(13*(m+1)/5)+d-1;
    int result=0;

    if(w>=0)
    result=w%7;
    else
    result=(w+700)%7;

    switch(result)
    {
    case 0: System.out.println("SUN"); break;
    case 1: System.out.println("MON"); break;
    case 2: System.out.println("TUE"); break;
    case 3: System.out.println("WED"); break;
    case 4: System.out.println("THU"); break;
    case 5: System.out.println("FRI"); break;
    case 6: System.out.println("SAT"); break;
    }


    }
    }
    ======================== 2 =====================
      import java.io.*;
      class putout{
      public void putout(int f,int x,int y){
      int i;
      int a[]= new int[40];
      System.out.println(" 日 一 二 三 四 五 六 "+" "+f+"月");
      for (i=0;i<x;i++)
      {System.out.print(" "); }
      for(i=x;i<x+y;i++)
      a[i]=i-x+1;
      for(i=x;i<x+y;i++)
      {
      if (i%7==0)
      System.out.print("\n");
      if (a[i]<10)
      System.out.print(" "+a[i]);
      else
      System.out.print(" "+a[i]);
      }
      System.out.println("\n");
      }
      }
      class st{
      public static void main(String args[])throws IOException{
      putout p=new putout();
      int year,mouth,y=1,t,i;
      InputStreamReader ir;
      BufferedReader in;
      ir=new InputStreamReader(System.in);
      in=new BufferedReader(ir);
      System.out.println("请输入一个年份");
      String s=in.readLine();
      year=Integer.parseInt(s);
      if((year%4==0 && year%100!=0)||(year%400==0))
      mouth=1;
      else
      mouth=0;
      y=year;
      for(i=1;i<year;i++)
      {if((i%4==0 && i%100!=0)||(i%400==0))
      y++;}
      y=y%7;
      for(i=1;i<13;i++){
      switch(i){
      case 1: {p.putout(1,y,31);y=(y+31)%7;break;}
      case 2: {p.putout(2,y,28+mouth);y=(y+28+mouth)%7;break;}
      case 3: {p.putout(3,y,31);y=(y+31)%7;break;}
      case 4: {p.putout(4,y,30);y=(y+30)%7;break;}
      case 5: {p.putout(5,y,31);y=(y+31)%7;break;}
      case 6: {p.putout(6,y,30);y=(y+30)%7;break;}
      case 7: {p.putout(7,y,31);y=(y+31)%7;break;}
      case 8: {p.putout(8,y,31);y=(y+31)%7;break;}
      case 9: {p.putout(9,y,30);y=(y+30)%7;break;}
      case 10: {p.putout(10,y,31);y=(y+31)%7;break;}
      case 11: {p.putout(11,y,30);y=(y+30)%7;break;}
      case 12: {p.putout(12,y,31);y=(y+31)%7;break;}
       }
      }
     }
    }

    发表于 @ 2008年05月13日 08:53:51|评论(loading...)|编辑

    新一篇: java 的居中显示代码 | 旧一篇: 数据库

    评论

    #yanmingzi 发表于2008-05-13 09:55:59  IP: 222.223.82.*
    生活在这种充满新技术的世界里太美了!
    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © yanmingzi