统计一个数字在排序数组(从小到大排序)中出现的次数。
// test20.cpp : 定义控制台应用程序的入口点。
//
include "stdafx.h"
include
include
include
include
include
include
include<string.h>
include
using namespace std;
class Solution {
public:
int GetNumberOfK(vector
int count = 0;
for (int i = 0;i < data.size();i++)
{
if(k==data[i])
count++;
}
return count;
}
};
int main()
{
Solution so;
//int count = so.FirstNotRepeatingChar("wangdanwang");
vector
int count = so.GetNumberOfK(data,5);
cout << count << endl;
cout << endl;
return 0;
}

浙公网安备 33010602011771号