zoukankan      html  css  js  c++  java
  • 第五周上机练习

    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);
              }
          }
  • 相关阅读:
    RabbitMq学习4-发布/订阅(Publish/Subscribe)
    RabbitMq学习3-工作队列(Work queues)
    《大型网站技术架构》-读书笔记七:安全架构
    RabbitMq学习2-php命令行模式测试rabbitmq
    《大型网站技术架构》-读书笔记六:可扩展架构
    RabbitMq学习1-介绍、安装和配置
    《大型网站技术架构》-读书笔记五:伸缩性架构
    C#构建树形数据结构
    数据结构和算法(一)概念
    C# 简介
  • 原文地址:https://www.cnblogs.com/z118127/p/12619190.html
Copyright © 2011-2022 走看看