#include <iostream>
#include<map>
#include<string>
using namespace std;
map<string,int> candidaes;
typedef map<string,int>::iterator VstrItor;
int invild =0;
unsigned int Addcandidate(char* pCandidateName)
{
if(NULL == pCandidateName )
{
return -1;
}
string temp(pCandidateName);
VstrItor it = candidaes.find(temp);
if(it!= candidaes.end())
{
return 0;
}
else
{
candidaes[temp]=0;
return 1;
}
}
void vote(char* pCandidateName)
{
if(NULL == pCandidateName)
return ;
string temp(pCandidateName);
VstrItor it = candidaes.find(temp);
if(it==candidaes.end())
{
invild++;
}
else
{
it->second++;
}
}
unsigned int getVoteResult(char* pCandidateName)
{
if(pCandidateName == NULL)
return invild;
else
return candidaes.find(pCandidateName)->second;
}
void clear()
{
candidaes.clear();
invild =0;
}
int main()
{
cout << "Hello World!" << endl;
return 0;
}
vote
猜你喜欢
转载自blog.csdn.net/libin88211/article/details/46933913
今日推荐
周排行