[数据结构]用哈希统计整数次数

我的题目【为什么输不出次数】
【问题描述】

用HASH方法统计整数出现的次数

【输入形式】

以逗号分隔,#结尾的整数
【输出形式】

等式。左侧为排序好的整数,右侧为其出现的次数。

【样例输入】

2,6,7,13,18,3,6,1,3,7#
【样例输出】

1=1
2=1
3=2
6=2
7=2
13=1
18=1
代码如下
#include<stdio.h>

typedef struct hx{
int key;
int num;

}hx;

int main()
{
int s,i=0,max,j,w;
char c;
int a[1000];
scanf("%d%c",&s,&c);
a[i]=s;
max=s;
while(c!='#'){

scanf("%d%c",&s,&c);
if(max<s)max=s;
i++;
a[i]=s;
}
hx b[100];

for(j=1;j<=max;j++)
{
b[j].key=j;
b[j].num=0;

}
for(j=0;j<=i;j++)
for(w=1;w<=max;w++)
{
if(a[i]==b[w].key)b[w].num=b[w].num+1;
}
for(w=1;w<=max;w++)
{
if(!b[w].num)
{
printf("%d=%d\n",b[w].key,b[w].num);

}
}

return 0;
}

定义一个数组初始化元素为0,循环输入遇到#结束
循环: 输入s
a[s]++
哈希表 key 存s value存a[s]
循环结束