• 第五周上级作业


    1.package finish;
    public class csy {
        public static void main(String[] args) {
               for (int i = 100; i <= 999; i++) {
                    int a = i / 1 % 10;//个位
                    int b = i / 10 % 10;//十位
                    int c = i / 100;//百位
                    if (a * a * a + b * b * b + c * c * c == i) {
                        System.out.print(i + " ");
                    }
    
                }
            }
    }

    2.package finish;
    public class csy {
        public static void main(String[] args) {
          for(int i=1;i<=6;i++){
          for (int j=1;j<=i;j++){
               System.out.print(j);
              }
              System.out.println();
             }
            }
        }

    package finish;
    public class csy {
        public static void main(String[] args) {
            for(int i=1;i<=6;i++){
              for (int j=1;j<=7-i;j++){
                   System.out.print(j);
                  }
                  System.out.println();
                 }
                }
            }

    package finish;
    public class csy {
        public static void main(String[] args) {
            for(int i=1;i<7;i++) {
                for (int k = 1; k <7-i ; k++) {
                    System.out.print(" ");
                }
                for(int j=i;j>0;j--) {
                    System.out.print(j);
                }
                System.out.println();
            }
        }
    }

    package finish;
    public class csy {
        public static void main(String[] args) {
            for(int i=6;i>0;i--) {
                for(int k=0;k<6-i;k++) {
                    System.out.print(" ");
                }
                for(int j=1;j<=i;j++) {
                    System.out.print(j);
                }
                System.out.println("");
            }
        }
    }

    3.package finish;
    import java.util.*;
    public class csy {
        public static void main(String[] args) {
             int day=0;
                int month=0;
                int year=0;
                int sum=0;
                int leap;
                System.out.println("请输入年,月,日");
                Scanner csy=new Scanner(System.in);
                year=csy.nextInt();
                month=csy.nextInt();
                day=csy.nextInt();
                switch(month)   
                {
                case 1:
                    sum=0;break;
                case 2:
                    sum=31;break;
                case 3:
                    sum=59;break;
                case 4:
                    sum=90;break;
                case 5: 
                    sum=120;break;
                case 6:
                    sum=151;break;
                case 7:
                    sum=181;break;
                case 8:
                    sum=212;break;
                case 9:
                    sum=243;break;
                case 10:
                    sum=273;break;
                case 11:
                    sum=304;break;
                case 12:
                    sum=334;break;
                default:
                    System.out.println("请正确的输入年,月,日");break;
                    }
                sum=sum+day;
                if(month>=0&&month<=12&&day>=1&&day<=31)
                  {
                if(year%400==0||year%4==0&&year%100!=0)
                {   leap=1;
                }else{
                    leap=0;
                }
                if(leap==1&&month>2)
                {
                    sum++;
                    System.out.println(year+"年"+month+"月"+day+"号是这一年的第"+sum+"天。");
                }else {
                    System.out.println(year+"年"+month+"月"+day+"号是这一年的第"+sum+"天。");
                        }
                    }
                }
            }

    4.package finish;
    import java.util.*;
    public class csy {
        public static void main(String[] args) {
                int a, b, c, d, e, x;
                Scanner sc = new Scanner(System.in);
                System.out.println("输入数字:");
                e = sc.nextInt();
                a = e / 1000;
                b = e / 100 % 10;
                c = e / 10 % 10;
                d = e % 10;
                x = d * 1000 + c * 100 + b * 10 + a;
                System.out.println("反转后数为:" + x);
                }
                }

  • 相关阅读:
    如何理解css3 -webkit-animation-fill-mode属性值为both时的使用方法
    关于对canvas.beginPath()的理解
    [cf10E]Greedy Change
    [atAGC055B]ABC Supremacy
    [loj6734]图上的游戏
    [gym102412D]The Jump from Height of Self-importance to Height of IQ Level
    [Aizu1410]Draw in Straight Lines
    [Aizu2993]Invariant Tree
    [zoj3990]Tree Equation
    [hdu6326]Monster Hunter
  • 原文地址:https://www.cnblogs.com/csy521/p/12618920.html
Copyright © 2020-2023  润新知