Pagini recente » Cod sursa (job #2229256) | Cod sursa (job #1218500) | Cod sursa (job #495462) | Cod sursa (job #260233) | Cod sursa (job #1045777)
#include <iostream>
#include<fstream>
#include<vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
#define prime 666013
vector <int> H[prime];
int Cauta(vector <int>H[prime], int x)
{
int unde=x%prime;
for(int i=0;i<H[unde].size();i++)
if(H[unde][i]==x)
return 1;
return 0;
}
void Insert(vector <int> H[prime],int x)
{
if(Cauta(H,x))
return;
int unde=x%prime;
H[unde].push_back(x);
}
int Sterge(vector <int>H[prime], int x)
{
int unde=x%prime;
for(int i=0;i<H[unde].size();i++)
if(H[unde][i]==x)
{
H[unde][i]=H[unde].back();
H[unde].pop_back();
return 1;
}
return 0;
}
int main()
{
int el,i,op,N;
cin>>op;
cout<<endl;
if(op==1)
{
cin>>el;
Insert(H,el);
}
else
if(op==2)
{
cin>>el;
Sterge(H,el);
}
else
if(op==3)
{
cin>>el;
}
return 0;
}