输入一个正整数n,然后读取n个正整数,a1,a2,a3,~,an,最后在读入一个正整数m。统计n个正整数中有多少个数的值小于m。
样例输入:5
1 6 4 23 10
7
样例输出:3
下面贴出代码:
package cn.zimo.algorithm;import java.util.Scanner;/*** 统计* @author 子墨* @date 2018年4月26日 下午2:16:33*/
public class Demo11 {public static void main(String[] args) {int n,m,count=0;int[] a=new int[100];Scanner scan=new Scanner(System.in);n=scan.nextInt();for(int i=0;i<n;i++) {a[i]=scan.nextInt();}m=scan.nextInt();for(int i=0;i<n;i++) {if(a[i]<m) {count++;}}System.out.println(count);}}