统计输入的一行字符串中各个字符出现的次数。算法:先输入一个字符串,对串中每一个字符,先到链表上逐个结点查找。若找到,给该字符频数加 1:否则为该字符产生一个结点,并插入链首。#include “stdio.h“struct nodechar c;int count;struct node *next;#define ND struct node#define NP struct node*void print(NP h)while(_)printf(“%c,%dn“,h-c,h-count);h=h-next;NP search(NP h,char ch)NP p; p=h;while(p!=NULL)if(p-c=ch)p-count+; break; elsep=p-next;if(p=NULL)p=_;p-c=ch; p-count=1;p-next=h;h=p;return h;main()char s300,*p=s; NP h;gets(s); h=NULL;while(*p!=0)h=search(h,*p); _;print(h);