| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 343 人关注过本帖
标题:求助~~没有错误提示,就是无法正常运行,求各位牛人指导!
只看楼主 加入收藏
lizhao180
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-3-25
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
求助~~没有错误提示,就是无法正常运行,求各位牛人指导!
这是我写的LZW的压缩算法,编译,链接都没有错误,就是运行不下去,请各位帮忙指点一下吧~~多谢了!!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>

void compress_f(void);
void display_f(void);
char getcode(char *t);



struct dictionary{
        char data[256];         //二进制数据
        char code;         //字典代码
        struct dictionary *next;//节点指针
        struct dictionary *pro;
};
struct dictionary *head,*the,*first;//头指针、当前指针


void main ( )
{   
        system("cls");
        compress_f();
        display_f();

        
        
}
void compress_f()//LZW
{   int i,j;
        char d[256],c[256];
        char p[256],s,t[256];//前缀、后缀、当前字符
        printf("请输入二进制数:");
        scanf("%s",d);        
        head=(struct dictionary*)malloc(sizeof(struct dictionary));
    sprintf(p,"%c",d[0]);
        the=head->next;
        the->pro=head;
        first=head;        
    strcpy(the->data,p);
    the->code=':';
        p[0]='\0';
        j=1;
    for(i=1;i<256;i++)
        {   the=(struct dictionary*)malloc(sizeof(struct dictionary));
            the=head->next;
                head=the->pro;
            sprintf(p,"%s%c",p,d[i-1]);
            s=d[i];
            sprintf(t,"%s%c",p,s);
        if(getcode(t))
                        c[i]=getcode(t);
                else
                {strcpy(the->data,t);
                 the->code=head->code;}
                 
        }
        printf("压缩代码为:%s\n",c);
}
char getcode(char *t)
{
        dictionary *p;
        char *y;
        p=first->next ;
        while(p!=NULL)
        {
                y=p->data;
                if(strcmp(y,t)==0)
                        return(p->code);
                else p=p->next ;
        }
}
void display_f(void)
{
        int count=0;
        printf("data           code\n");
        printf("-----------\n");
        the=head->next;
        while(the!=NULL)
        {
                printf("  %-20s%3s\n",the->data,the->code);
                count++;
                the=the->next;
        }
}
搜索更多相关主题的帖子: dictionary 二进制 字典 
2011-03-25 12:36
bccn250
Rank: 5Rank: 5
等 级:职业侠客
帖 子:154
专家分:379
注 册:2010-5-25
收藏
得分:10 
不知道你想做什么,

不过,是不是 你早请的 空间没释放???
2011-03-25 12:50
bccn250
Rank: 5Rank: 5
等 级:职业侠客
帖 子:154
专家分:379
注 册:2010-5-25
收藏
得分:0 
刚刚编译了下,getcode 没反回值
2011-03-25 12:57
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:10 
编译没错  逻辑不知道有多少错误  呵呵
自己画内存图 自己找  自己debug

                                         
===========深入<----------------->浅出============
2011-03-25 15:18
快速回复:求助~~没有错误提示,就是无法正常运行,求各位牛人指导!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017199 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved