11-Hash 1 Phone chat maniac (25 min)
Given a large number of mobile phone users call logs, find the most calls in the chat madman.
Input format:
The input first gives a positive integerN (≤10? ) 5?? ) for the number of call logs. Then n lines, each row gives a call record. For simplicity, only the 11-digit mobile number of the dial-out party and the receiver is listed here, separated by a space.
Output format:
The phone number of the chat madman and the number of calls are given in a row, separated by a space. If such a person is not unique, then output the smallest number in the madman and its number of calls, and attach to the number of people who are tied to the madman.
Input Sample:
413005711862 1358862583213505711862 1308862583213588625832 1808792583215005713862 13588625832
Sample output:
13588625832 3
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define Keylength 13#define maxtablesize 100001typedef char elementtype[keylength];typedef int index;typedef struct lnode* ptrtolnode; struct Lnode{elementtype data;int cnt; Ptrtolnode Next;}; typedef ptrtolnode POSITION;TYPEDEF ptrtolnode list;typedef struct Tblnode *hashtable;struct tblnode {int TableSize; List Heads;}; HashTable createtable (int tablesize); Position Find (HashTable H, ElementType key); Index Hash (ElementType Key, int tablesize); int nextprime (int N); void Ins ERT (HashTable H, ElementType Key), void Scanandoutput (HashTable h); void destroytable (HashTable h); int main () {//freope N ("C:\\in.txt", "R", stdin), int N, i;scanf ("%d", &n); HashTable H; ElementType Key; h = createtable (n*2); for (i=0; i<n*2; i++) {scanf ("%s", key); Insert (H, key);} Scanandoutput (h);D estroytable (h); return 0;} void Destroytable (HashTable H) {int i; Position P, Tmp;for (i=0; i
Phone Chat Maniac