散列学习


//整数的散列
#include<cstdio> using namespace std; int const Maxn = 100010; bool hashTable[Maxn] = {false}; //m个数在n个数中出现过的散列 int main(){ int n,m,x;//x表示出现的数,n表示对比的数的数量,m表示对比的数的数量 scanf("%d%d",&n,&m); for(int i=0;i<n;i++){ scanf("%d",&x); hashTable[x] = true; } for(int i=0;i<m;i++){ scanf("%d",&x); if(hashTable[x] == true){ printf("%d出现过\n",x); }else{ printf("%d没出现过\n",x); } } return 0; }

  

猜你喜欢

转载自www.cnblogs.com/Jason-LinkStart/p/12919512.html