0
点赞
收藏
分享

微信扫一扫

智能统计系统

爱做梦的夏夏 2022-02-26 阅读 29

(1)package tan;
import java.io.InputStream;
import java.util.Scanner;
public class X {
    public static void main(String[] args) {
        int y,m;
        System.out.println("请输入年份:");
     Scanner sin=new Scanner(System.in);
     y=sin.nextInt();
     System.out.println("请输入月份:");
     m=sin.nextInt();
     int d=0;
     switch (m) {
     case 1:
     case 3:
     case 5:
     case 7:
     case 8:
     case 10:
     case 12: {
         d = 31;
         break;
     }
     case 4:
     case 6:
     case 9:
     case 11: {
         d = 30;
         break;
     }
     case 2: {
         if ((y % 100 !=0 &&y % 4 == 0) || (y % 100 == 0 && y%400==0)) {
             d = 29;
         } else {
             d = 28;
         }
     }
     default:
         break;
    }
    System.out.println(d);
}
}

(2)package tan;
public class X {
    public static void main(String[] args) {
    double i=0.0005;int k=0;
    double j=8844.43;
    for(;i<=j;i*=2) {
        k++;
    }
    System.out.println(k);
}
}

(3)package tan;
public class X {
    public static void main(String[] args) {
        for(int i =2; i<=99; i++)
        {
            if(IsTG(i))
                System.out.print(i+"\t");
        }
    }
    static boolean IsTG(int x)
    {
        boolean b=false;
        if(x>=1 && x<=9)
            {
            if(x== (x*x)%10)   b=true;
            }              
        else if(x>=10 && x<=99)
            {
            if(x == (x*x)%100)   b=true;
            }              
        return b;
}
}

举报

相关推荐

0 条评论