zoukankan      html  css  js  c++  java
  • 哈希表3

    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.
    ", s->userName, s->phoneNumber);*/
            
            /*插入到哈希表中*/
            InsertUserAndPhone(s);
        }  
        
        printf("all the usercnt = %d.
    ", userCnt);
      
        /* 测试findPhoneNumber */
        char phoneToFind[MAX_PHONENUM_LEN];
        char *username = "betty";
        if (SUCCESS != findPhoneNumber(username, phoneToFind)) 
        {
            printf("error!!!!
    ");
        }
        else
        {
            printf("%s 's phone number is %s.
    ", username, phoneToFind);
        }
        
        
        /* 测试getAllUserAndPhone*/
        if (SUCCESS != getAllUserAndPhone())   
        {
            printf("error!!!!
    ");
        }
        else
        {
            for (i = 0; i < userCnt; ++i)
            {
                printf("%s 's phone number is %s.
    ", userAndPhone[i].userName, userAndPhone[i].phoneNumber);
            }
        }
    
        /* 测试deleteAllUserAndPhone */  
        deleteAllUserAndPhone();
        printf("userCnt = %d.
    ", userCnt);
        if (SUCCESS != findPhoneNumber(username, phoneToFind)) 
        {
            printf("error!!!!
    ");
        }
        else
        {
            printf("%s 's phone number is %s.
    ", phoneToFind);
        }
        
        return 0;  
    }  
  • 相关阅读:
    森林 BZOJ 3123
    calc BZOJ 2655
    修路 BZOJ 4774
    无聊的计算器【数论多合一】
    矩阵乘法 BZOJ 2738
    K大数查询 BZOJ 3110
    发展城市 BZOJ 3700
    降雨量 BZOJ 1067
    chrome中showModalDialog解决方案
    MFC webbrowser读取文档的meta分析
  • 原文地址:https://www.cnblogs.com/gardonkoo/p/7611186.html
Copyright © 2011-2022 走看看