数据结构(3)

实验步骤:
任务:要求使用自定义函数来实现
输入一段文本,统计每个字符出现的次数,按照字符出现次数从多到少,依次输出,格式如下:
字符1-个数
字符2-个数
......
解题思路:
构建结构体,然后将数据依次输入结构体中,随后进行排序输出。
算法代码如下:

#include
#include
struct s{
	char a;
	int b;
};
void addup(char s[100]){
	int h=0;
	int m=0;
	int n[256] = {0};
	struct s a[256];
	struct s b[256];
	for(int i=0;i

你可能感兴趣的:(数据结构,c++)