1.5 12: The number of the same number as the specified number

Description
Output the number of the same number as the specified number in an integer sequence.

Input The
input consists of 2 lines: the
first line is N and m, which represent the length of the integer sequence (N <= 100) and the specified number, separated by a space;
the second line is N integers, and the integers are separated by a space.
Output The
output is the same number as m among the N numbers.
Sample input
3 2
2 3 2
Sample output
2

#include <iostream>
using namespace std;
int main()
{
    
    
	int n, m,times=0,temp;
	cin >>n>>m;
	for(int i=0;i<n;i++)
	{
    
    
		cin>>temp;
		if(temp==m)
		{
    
    
			times++;
		}
	}
	cout<<times<<endl;
	return 0;
}

Guess you like

Origin blog.csdn.net/yansuifeng1126/article/details/111994844