小红的正整数计数

实现代码:

java 复制代码
public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int l = scanner.nextInt();
        int r = scanner.nextInt();

        int n = 0;
        for(int i = l ; i <= r; i ++){
            if(i % 2 == 0){
                n ++;
            }
        }
        System.out.println(n);
        scanner.close();

    }
相关推荐
AnAnCode1 小时前
【时间轮算法-实战】Java基于Netty的 `HashedWheelTimer`快速搭建时间轮算法系统
java·开发语言·算法·时间轮算法
liu****1 小时前
12.C语言内存相关函数
c语言·开发语言·数据结构·c++·算法
while(1){yan}1 小时前
JAVA单例模式
java·单例模式
没有bug.的程序员1 小时前
Async Profiler:最精准的火焰图工具
java·jvm·spring·对象分配·async profiler
FPGA_无线通信1 小时前
OFDM 精频偏补偿
算法·fpga开发
程序员-King.1 小时前
day109—同向双指针(字符串)—每个字符最多出现两次的最长子字符串(LeetCode-3090)
算法·leetcode·双指针
青山的青衫1 小时前
【单调栈和单调队列】LeetCode hot100+面试高频
算法·leetcode·面试
金士顿1 小时前
Ethercat耦合器添加的IO导出xml 初始化IO参数
android·xml·java
俊俊谢1 小时前
【浮点运算性能优化】浮点转定点算法库的多平台通用移植方案与性能评估优化
算法·性能优化·c·浮点转定点·多平台移植