• 第五周上机练习


    1.

    package test;
    public class LH {
    
        public static void main(String[] args) {
            int i;
            for(i=100;i<1000;i++){
                int b=i/100;
                int s=i/10%10;
                int g=i%10;
                if(i==g*g*g+b*b*b+s*s*s){
                    System.out.println(i);
                }
            }
      }
    }

    2.

    package test;
    
    public class LH {
    
        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 test;
    
    public class LH {
    
        public static void main(String[] args) {
            for(int i=6;i>=1;i--){
                for(int j=1;j<=i;j++){
                    System.out.print(j);
                }
                    System.out.println();
            }
        }
    }
    package test;
    
    public class LH {
    
        public static void main(String[] args) {
            for (int i = 1; i <= 6; i++) {
                for (int l = 1; l < 7 - i; l++) {
                    System.out.print(" ");
                }
                for (int j = i; j > 0; j--) {
                    System.out.print(j);
                }
                System.out.println();
            }
        }
    }
    package test;
    
    public class LH {
    
        public static void main(String[] args) {
            int i, j, n;
            for (i = 6; i > 0; i--) {
                for (n = 0; n <= 6 - i; n++) {
                    System.out.print(" ");
                }
                for (j = 1; j <= i; j++) {
                    System.out.print(j);
                }
                System.out.println();
            }
    
        }
    }

    3.

    package test;
    
    import java.util.*;
    
    public class LH {
    
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            System.out.println("请输入年份:");
            int year = input.nextInt();
            System.out.println("请输入月份:");
            int month = input.nextInt();
            System.out.println("请输入日子:");
            int day = input.nextInt();
            int total = 0;
            for (int i = 1; i < month; i++) {
                switch (i) {
                case 4:
                case 6:
                case 9:
                case 11:
                    total += 30;
                    break;
                case 2:
                    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
                        total += 29;
                    else
                        total += 28;
                    break;
                default:
                    total += 31;
                    break;
                }
            }
            total += day;
            System.out.println("该天是第" + total + "天");
    
        }
    }

    4.

    package test;
    import java.util.Scanner;
    public class LH {
          public static void main(String[] args) {
              Scanner sc = new Scanner(System.in);
              System.out.println("请输入一个四位数:");
              int i = sc.nextInt();
              int q = i/1000%10;
              int b = i/100%10;
              int s = i/10%10;
              int g = i%10;
              int n;
              reverse = g*1000+s*100+b*10+q;
              System.out.println("反转后为:"+n);
              }
          }
  • 相关阅读:
    初识Django-前后端不分离(一)
    虚拟环境的搭建
    python+request+Excel做接口自动化测试(二)
    使用postman+newman+python做接口自动化测试
    如何处理接口响应结果分析
    request使用的封装
    python中unittest的使用
    使用python的接口测试环境搭建及使用
    关于测试流程的指导心得
    Redis 学习
  • 原文地址:https://www.cnblogs.com/z118127/p/12619190.html
Copyright © 2020-2023  润新知