当前位置: 首页 > news >正文

平时作业(偷懒)

平时作业

一.

package zuoye;
​
public class zuoye01 {
    public static int Random(int n) {
        return (int)(n * Math.random());
    }
​
    public static void main(String[] args) {
        int n = 100; // 假设n为100,可以根据需求修改
        int[] random = new int[50];
        for (int i = 0; i < 50; i++) {
            random[i] = Random(n);
        }
​
        int max = random[0];
        int min = random[0];
        int count = 0;
        for (int num : random) {
            if (num > max) {
                max = num;
            }
            if (num < min) {
                min = num;
            }
            if (num >= 60) {
                count++;
            }
        }
​
        System.out.println("最大值: " + max);
        System.out.println("最小值: " + min);
        System.out.println("大于等于60的个数: " + count);
    }
}

二.

package zuoye;
class Vehicle1{
    private int speed;
    private int size;
​
    public void move() {
​
    }
    public void setSpeed(int speed) {
        this.speed = speed;//看不懂
    }
    public void speedUp() {
        speed++;
    }
    public void speedDown() {
        if(speed>=0) {
            speed--;
        }
    }
    public int getSpeed() {
        return speed;
    }
    public int getSize() {
        return size;
    }
    public void setSize(int size) {
        this.size = size;
    }
}
​
public class Vehicle {
    public static void main(String[] args) {
        Vehicle1 v1 = new Vehicle1();
        v1.setSpeed(10);
        v1.setSize(10);
        System.out.println("初始速度"+v1.getSpeed());
        System.out.println("初始体积"+v1.getSize());
        v1.speedUp();
        System.out.println("加速后速度"+v1.getSpeed());
        v1.speedDown();
        System.out.println("减速后速度"+v1.getSpeed());
    }
}

打卡!打卡!打卡!打卡!打卡!

http://www.dtcms.com/a/59596.html

相关文章:

  • 一、Jenkins简单配置(使用语言、凭证、SSH)
  • WinUI 3 支持的三种窗口 及 受限的窗口透明
  • FPGA设计时序约束用法大全保姆级说明
  • 基于LabVIEW的脚本化子VI动态生成
  • 将图片存储至阿里云 OSS
  • 2025数据存储技术风向标:解析数据湖与数据仓库的实战效能差距
  • 基于yolov8的土豆马铃薯叶子病害检测系统python源码+pytorch模型+评估指标曲线+精美GUI界面
  • OSPF报文分析
  • 深度学习模型Transformer核心组件—前馈网络FFN
  • python如何把多维列表转换为dataframe
  • 【RabbitMQ | 第1篇】Erlang 和 RabbitMQ 的下载安装
  • easyconnect下服务器联网
  • 大白话JavaScript原型链查找机制与继承实现原理
  • Service与Ingress:如何将你的应用暴露给世界
  • 嵌入式 ARM Linux 系统构成(6):应用层(Application Layer)
  • VSTO(C#)Excel开发1:起步 示例项目
  • 【从零开始学习计算机科学】计算机组成原理(二)信息表示与编码
  • Ardupilot开源无人机之Geek SDK进展2025Q1
  • 用AI学习ANN人工神经网络2——什么是Transformer
  • Element使用
  • 力扣72题编辑距离
  • 【弹性计算】异构计算云服务和 AI 加速器(三):GPU 虚拟化技术
  • nuxt2 打包优化使用“compression-webpack-plugin”插件
  • Docker常用命令清单
  • python用户图形界面wxpython库安装与使用
  • S19文件格式详解:汽车ECU软件升级中的核心镜像格式
  • 谷歌浏览器中 Google 翻译无法使用的解决办法
  • AcWing 5538. 回文游戏 博弈论
  • 从零开始学机器学习——网络应用
  • Spring Batch 概览