码迷,mamicode.com
首页 > 其他好文 > 详细

哈希表3

时间:2017-09-29 16:39:18      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:insert   ror   sizeof   mes   max   for   class   number   enum   

int main()
{  
    char userNames[4][10] = {"joe", "betty", "betty", "xxx" }; 
    char phoneNums[4][10] = {"110", "119", "999", "911"};
    
    PhoneBook *s, *tmp;
    int i=0;  
  
    for (; i < 4; ++i)
    {
        s = (PhoneBook*)malloc(sizeof(PhoneBook));  
        strcpy(s->userName, userNames[i]);  
        strcpy(s->phoneNumber, phoneNums[i]); 
        /*printf("insert %s and %s.\n", s->userName, s->phoneNumber);*/
        
        /*插入到哈希表中*/
        InsertUserAndPhone(s);
    }  
    
    printf("all the usercnt = %d.\n", userCnt);
  
    /* 测试findPhoneNumber */
    char phoneToFind[MAX_PHONENUM_LEN];
    char *username = "betty";
    if (SUCCESS != findPhoneNumber(username, phoneToFind)) 
    {
        printf("error!!!!\n");
    }
    else
    {
        printf("%s ‘s phone number is %s.\n", username, phoneToFind);
    }
    
    
    /* 测试getAllUserAndPhone*/
    if (SUCCESS != getAllUserAndPhone())   
    {
        printf("error!!!!\n");
    }
    else
    {
        for (i = 0; i < userCnt; ++i)
        {
            printf("%s ‘s phone number is %s.\n", userAndPhone[i].userName, userAndPhone[i].phoneNumber);
        }
    }

    /* 测试deleteAllUserAndPhone */  
    deleteAllUserAndPhone();
    printf("userCnt = %d.\n", userCnt);
    if (SUCCESS != findPhoneNumber(username, phoneToFind)) 
    {
        printf("error!!!!\n");
    }
    else
    {
        printf("%s ‘s phone number is %s.\n", phoneToFind);
    }
    
    return 0;  
}  

 

哈希表3

标签:insert   ror   sizeof   mes   max   for   class   number   enum   

原文地址:http://www.cnblogs.com/gardonkoo/p/7611186.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!