没有合适的资源?快使用搜索试试~ 我知道了~
数据结构 作业哈夫曼、排序二叉树
需积分: 18 14 下载量 174 浏览量
2009-03-09
02:35:01
上传
评论
收藏 2KB TXT 举报
温馨提示
试读
6页
哈夫曼 编码 和排序二叉树 写的比较简单 只是完成了基本功能
资源推荐
资源详情
资源评论
///¹þ·òÂü
#include "stdafx.h"
#include "stdlib.h"
int a[10];
struct node
{
int value;
int left;
int right;
};
struct linknode
{
node value;
linknode *next;
};
void sort(int a[],int index)
{
int temp = 0;
for (int i=index;i<10;i++)
{
for (int j=i;j<10;j++)
{
if (a[i]>a[j])
{
temp = a[i];
a[i] =a[j];
#include "stdafx.h"
#include "stdlib.h"
int a[10];
struct node
{
int value;
int left;
int right;
};
struct linknode
{
node value;
linknode *next;
};
void sort(int a[],int index)
{
int temp = 0;
for (int i=index;i<10;i++)
{
for (int j=i;j<10;j++)
{
if (a[i]>a[j])
{
temp = a[i];
a[i] =a[j];
a[j] =temp;
}
}
}
}
int main(int argc, char* argv[])
{
linknode *root =(linknode *)malloc(sizeof(linknode));
linknode *list = root;
for (int i=0;i<10;i++)
{
a[i] =i+1;
}
for (int j=0;j<10;j++)
{
sort(a,j);
list->next =(linknode *)malloc(sizeof(linknode));
node temp;
temp.value = a[j] +a[j+1];
temp.right =a[j+1];
temp.left =a[j];
list->value =temp;
list =list->next;
a[j+1] =a[j] +a[j+1];
}
}
}
}
int main(int argc, char* argv[])
{
linknode *root =(linknode *)malloc(sizeof(linknode));
linknode *list = root;
for (int i=0;i<10;i++)
{
a[i] =i+1;
}
for (int j=0;j<10;j++)
{
sort(a,j);
list->next =(linknode *)malloc(sizeof(linknode));
node temp;
temp.value = a[j] +a[j+1];
temp.right =a[j+1];
temp.left =a[j];
list->value =temp;
list =list->next;
a[j+1] =a[j] +a[j+1];
剩余5页未读,继续阅读
资源评论
Donneyming
- 粉丝: 15
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功