【洛谷学习自留】P1046 陶陶摘苹果

2023-12-30 05:42:13

解题思路:

简单的比较录入值,使用for循环遍历比较就行。

代码实现:

import java.util.Scanner;

public class P1046 {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int [] a = new int[10];
        for (int i = 0; i < 10; i++) {
        a[i]=sc.nextInt();
        }
            int height = sc.nextInt();
        height+=30;
        int count = 0;
        for (int i = 0; i < 10 ; i++) {
            if(a[i]<=height){
                count++;
            }
        }
        System.out.println(count);
    }
}

文章来源:https://blog.csdn.net/m0_61635914/article/details/135229641
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。