Problem1684--统计小于等于m的个数

1684: 统计小于等于m的个数

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 21  Solved: 14
[Status] [Submit] [Creator:]

Description

输入一个正整数n, 再读入一个正整数m,然后读取n个整数正整数a1,a2,……,an 。统计a1,a2,……,an中有多少个整数的值小于等于m。

Input

第一行输入一个整数n和一个整数m。
第二行输入n个正整数。
n不超过50000.m以及输入的数据不超过100000.

Output

n个整数中小于等于m的个数。

Sample Input Copy

样例1
3 4
1 5 2

样例2
10 7
7 6 5 9 8 7 80 3 200 7

Sample Output Copy

样例1
2

样例2
6

HINT

一、while循环结构
 whlie(循环条件)
{
     循环操作语句;
}
例题: 输入n,输出s=1+2+3+4+……+n的值(用while实现)
  #include<cstdio>
  using namespace std;
  int main()
  {
      int n,s,i;
      scanf("%d",&n);
      s=0;i=1; 
      while(i<=n)      //如果满足括号的条件就继续进入循环
      {
          // 循环里面做两件事,对s加i,和对i的改变
          s=s+i;
          i=i+1;
      }
      printf("%d\n",s);
      return 0;
  }

二、解题思路:
while(n大于0){
        每次输入一个数字a;
        如果a小于等于m,那么count统计加1;
    }
最后输出count记录的小于等于m总个数;


Source/Category