小编vpa*_*ial的帖子

'由于超时而终止'.需要帮助优化我的代码

我正在尝试实施字典.如果您在我的代码中发现缺陷而不是改变整个逻辑,我将不胜感激.

样本输入
3
sam 99912222
tom 11122222
harry 12299933
sam
edward
harry

样品输出:
sam = 99912222
未找到
harry = 12299933

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

struct Dict {
  char key[100];
  int value;
};

struct Dict *array;
int inputsize;

int getHashKey(char *key){
  return strlen(key)%inputsize;

}

void insert(char *key, int value){
  int i =0;
  int hashkey = getHashKey(key);

  /* Already inserted. Return */
  if(!strcmp (array[hashkey].key,key)){
   return;
  }

  /* Check if empty space. else, Get the next available space. */ …
Run Code Online (Sandbox Code Playgroud)

c arrays dictionary

-3
推荐指数
1
解决办法
74
查看次数

标签 统计

arrays ×1

c ×1

dictionary ×1