最新日志

发表于:2008-5-13 19:03:06
标签:无标签

0

0513_2008_问题解决了

上次数据结构的习题犯了个很小的错误,在malloc后的struct node后误加了个*号,只在堆中分配了些指针空间,然后又复制粘贴了好几次,一时间竟没发现!(关键是VC6不报错,而且运行皆正确的结果迷惑了俺的思维!),现在看来这就像一个3*7=27的错误一样,有时眼神确实很重要!呵呵。。o(∩_∩)o...

点击此处查看原文 >>

系统分类: 生活点滴   |    用户分类: 无分类    |    来源: 原创

评论(0) | 阅读(29)
发表于:2008-5-11 21:09:12
标签:无标签

0

0511_2008_关于链表的求助!

写了个书本上的作业题,就是多项式相加的数据结构题

但是问题出来了,在vc6下跑的好好的,到devcpp下报错,codeblocks下也报错,vs05下还报错!(但上述环境调试时结果却都正确)

郁闷了一个周末,还是没有解决,只得把程序贴出来,望有高人指点

程序如下(有一些注释掉的无用代码并未删除,还有就是复制进来时EDN的blog会自动填一些""之类的符号,也不知为何):

#include
#include
#include
  struct node
{
    int exponent;
    float coefficient;
     struct node *next;
}  ;
void Init( struct node *&chainToInit)
{
    chainToInit=( struct node*)malloc(sizeof( struct node *));
    (chainToInit)->exponent=0;
    (chainToInit)->coefficient=0;
    (chainToInit)->next=NULL;
}
void Insert(struct node *&chainToInsert,int exponentToInsert,float coefficientToInsert)
{
     float sum="1";
     struct node *head=chainToInsert;
     struct node *temporaryNode=NULL;
     //struct node *temporaryNode2=NULL;
     struct node *precursorOfTheNode=chainToInsert;

    if(exponentToInsert<(chainToInsert)->exponent)
    {
         temporaryNode=( struct node*)malloc(sizeof( struct node *));
         temporaryNode->exponent=exponentToInsert;
         temporaryNode->coefficient=coefficientToInsert;
         temporaryNode->next=chainToInsert;
         chainToInsert="temporaryNode";
         chainToInsert= temporaryNode;

    }
    else if(exponentToInsert==(chainToInsert)->exponent)
    {
        (chainToInsert)->coefficient+=coefficientToInsert;
    }
    else if(exponentToInsert>(chainToInsert)->exponent)
    {
        while((exponentToInsert>(chainToInsert)->exponent)&&((chainToInsert)->next)!=NULL)
        {
            precursorOfTheNode="chainToInsert";

             chainToInsert=(chainToInsert)->next;
         }
         if((chainToInsert)->next==NULL&&(exponentToInsert>(chainToInsert)->exponent))
        {
             temporaryNode=( struct node*)malloc(sizeof( struct node*));
             temporaryNode->exponent=exponentToInsert;
             temporaryNode->coefficient=coefficientToInsert;
             temporaryNode->next=NULL;
             (chainToInsert)->next=temporaryNode;
             chainToInsert="head";
        }
        else if((exponentToInsert<(chainToInsert)->exponent))
        {

             temporaryNode =(struct node*)malloc(sizeof( struct node*));
             temporaryNode->exponent=exponentToInsert;
             temporaryNode->coefficient=coefficientToInsert;
             temporaryNode->next=NULL;
             //temporaryNode->next=chainToInsert;
             //  printf("%3d  ********        %20f  \n",chainToInsert->exponent,chainToInsert->coefficient);
             //  printf("%3d  ********        %20f  \n", exponentToInsert, coefficientToInsert);
             //printf("%3d  ********        %20f  \n", temporaryNode->exponent, temporaryNode->coefficient);
             //free(chainToInsert);

             //fflush(precursorOfTheNode);

             temporaryNode->next=chainToInsert;
             precursorOfTheNode->next=temporaryNode;

             chainToInsert="head";


        }

        else if(exponentToInsert==(chainToInsert)->exponent)
        {
            sum="coefficientToInsert"+(chainToInsert)->coefficient;
            {
                if(sum==0&&exponentToInsert!=0)
                {
                    temporaryNode=(chainToInsert)->next;
                    (chainToInsert)->next=temporaryNode->next;
                    free(temporaryNode);
                    temporaryNode="NULL";
                    chainToInsert="head";
                }
                else if(sum!=0)
                {
                    (chainToInsert)->coefficient+=coefficientToInsert;
                    chainToInsert="head";
                }
            }

        }


    }}

 

void Display( struct node *chainToDisplay,int length)
{
    int i;


    while(chainToDisplay!=NULL)
    {
        printf("%3d          %20f  \n",chainToDisplay->exponent,chainToDisplay->coefficient);
        chainToDisplay="chainToDisplay-">next;
    }

    return;
}

 

 

 

 


void Add( struct node *&chainToAdd)
{
    //Insert( chainToAdd,-1,0);
 
       Insert(chainToAdd,2,3);
     //Insert(chainToAdd, 123,7);
     Insert(chainToAdd,3,9);

    return;
}
void Add2( struct node *&chainToAdd)
{
    //Insert( chainToAdd,-1,0);
 
       Insert(chainToAdd,9,7);
       Insert(chainToAdd,6,10);
       Insert(chainToAdd,5,7);
    return;
}

void Free( struct node *chainToFree)
{
    int i;
    int length="3";
     struct node *temporaryNode=NULL;
    for(i=0;i    {
        temporaryNode="chainToFree";
        chainToFree="chainToFree-">next;
        free(temporaryNode);
        temporaryNode="NULL";

 

 


    }
}


int main()
{
    struct node *chain=NULL;
    Init( chain);
    Add(chain);
       Add2(chain);
    Display( chain,3);
    //Free(chain);
    printf("Hello world!\n");
    return 0;
}

 

点击此处查看原文 >>

系统分类: 软件开发   |    用户分类: 无分类    |    来源: 原创

评论(0) | 阅读(28)
发表于:2008-5-6 22:29:06
标签:无标签

0

05-06-2008_uVision+Proteus

这两天在玩了玩Proteus,真是太棒了!

跑了几个程序,

哈哈哈,仅仅是记录一下,虽然很短。。。

点击此处查看原文 >>

系统分类: 生活点滴   |    用户分类: 无分类    |    来源: 原创

评论(0) | 阅读(39)
发表于:2008-4-2 22:19:55
标签:日记  verilog入门  

0

04-02-2008_实战verilog

fpga实验确实挺有意思的,虽然目前自己的水平还不高,只自学了半个月的verilog,只能写些小东西,呵呵...

实际上到目前为止也只写过两个程序,一个是电子琴,另一个是交通灯模拟程序。第一个太太太太简单了,就不写在这里了,下面发一个自己写的交通灯模拟的程序(注:由于写的匆忙,未设置初始状态,复位信号来时会出现一定的差错;另外,此处发的程序未加降频进程,实际很简单,自己加上就行了。)

程序如下:

module tLight( high,low,a,b,c,d,e,f,preclk,rst);
 
output [3:0] high;
output [3:0] low;
output a,b,c,d,e,f;
input preclk,rst;

 
 reg [3:0] high;
 reg [3:0] low;
reg clk;
reg a,b,c,d,e,f;
reg [1:0] state,next_state;
reg k;
reg clr;
 
 parameter     S_0=0;
 parameter S_1=1;
 parameter   S_2=2;
 parameter  S_3=3;
 parameter dont_care_state=2'bx;
 parameter dont_care_out=6'bx;
always@(posedge preclk)
  if(k==0)
    begin
    
          if(low>4'b0)     
            begin low="low-1"'b0001; clr<=0;        end
          else if(low==4'b0)
             begin if(high==4'b0)begin high<=4'b0001; low<=4'b0101;clr<=1; end
                   else begin high<=high-1;low<=9;clr<=0;end 
             end
    end
  else 
   begin
    
          if(low>4'b0)     
            begin low="low-1"'b0001;  clr<=0;    end
          else if(low==4'b0)
             begin if(high==4'b0)begin high<=4'b0000; low<=4'b0011;clr<=1; end
                   else begin high<=high-1;low<=9;clr<=0;end  
             end
    end


  always@( posedge clr or  posedge rst)
 if( rst==1)   state<=S_0 ;  else if (clr==1) state<=next_state; 

always@(state)
begin
 
     case(state)
    S_0: begin {a,b,c,d,e,f}=6'b100001;k=1;next_state<=S_1; end 
    S_1: begin {a,b,c,d,e,f}=6'b010010;k=0;next_state<=S_2; end
    S_2: begin {a,b,c,d,e,f}=6'b001100;k=1;next_state<=S_3; end
    S_3: begin {a,b,c,d,e,f}=6'b010010;k=0;next_state<=S_0; end
           
     default:begin {a,b,c,d,e,f}=dont_care_out;next_state=dont_care_state; end
     endcase
end
endmodule

点击此处查看原文 >>

系统分类: CPLD/FPGA   |    用户分类: 无分类    |    来源: 原创

评论(0) | 阅读(168)
发表于:2008-4-1 19:00:34
标签:无标签

0

04-01-2008_verilog真好用

学Verilog差不多半个月了啊,虽然是在课余时间学的......

虽然网上有不少人说在高层的设计上,它不如VHDL,但就目前的我来说,它真的比VHDL好用的多!

哎,今天去做实验,做了个电子琴的程序,其实并不难,只是调音很麻烦,费了不少功夫,即便如此,还是感觉FPGA的实验比汇编等好做的多!

 

 

点击此处查看原文 >>

系统分类: 自由话题   |    用户分类: 无分类    |    来源: 原创

评论(0) | 阅读(212)
发表于:2008-3-29 16:01:20
标签:日记  

0

03-29-2008_摆脱网通拨号程序

前些天教员让我们去摸一摸linux,做个串口通信的程序出来玩玩......呵呵,摸就摸呗,上手试了下,以硬盘引导的方式装了个红帽的Fedora Core 8,只是联网有些麻烦,河南网通貌似对拨号进行了加密,在linux下给的拨号程序又超级不好用,于是上网就成了不大不小的难题,但总是要上的,哎......

这年头不会用百度的可以说是半个傻帽了,还是赶快Baidu一下!

果然很快就找到了结果,如下:

1、先使用网通新版的拨号pppoe程序拨号连上网络,拨号完成后点开网上邻居→网络连接,在宽带下会出现一个叫“rwpppoe”的网络连接,注意此连接在网通拨号程序断开时会自动消失,以下过程必须再用网通自带的拨号程序完成拨号后执行。 

        2、在任务管理器结束网通的拨号程序,此时网络连接中“rwpppoe”连接不会自动化消失,右键单击“rwpppoe”图标→选择“属性”,在“rwpppoe”属性对话框中,选择“选项”→在“拨号选项”中把“提示名称、密码和证书”勾上→选择“确定 

       3、右键单击“rwpppoe”→选择“断开”,然后用“rwpppoe”拨号,这时会出现一个“连接rwpppoe”对话框,你会发现对话框中的用户名和你在网通拨号程序中输入的用户名不一样,把对话框中的用户名记下来,保存好,这个用户名就是就是我们所找的标准ppoe拨号程序的用户名,到此为止我们就可以和网通说byebye了 

      4、有了用户名就好办了,用xp自带的拨号程序新建一个ppPoe的宽带拨号连接吧,密码就是网通拨号程序的原密码,(网通拨号程序是对用户名进行了加密),然后拨号上去,看看是不是很爽,最起码节省了一大比系统开支,而且拨号速度特别快,再也没有网通拨号程序哪个漫长的疑似死机等待界面了:),或者直接把新的用户名和原密码输入到路由器的ppPoe选项里,步骤我就多说了,看路由器的说明书吧,总之终于不用再整 网通专用路由器 

好了,按上面的方法在windows中尝试了一下,成功的以PPPoE的拨号连接连上了网!

就写到这里,

    Now,转到linux下,赶紧yum update一下!

点击此处查看原文 >>

系统分类: 生活点滴   |    用户分类: 无分类    |    来源: 原创

评论(0) | 阅读(91)
发表于:2008-3-26 16:20:31
标签:日记  

0

03-26-2008

自己原先其实在EDNCHINA已经申请过一个号了,但是当时好像允许用中文名申请(但现在却不行了),虽然也能登陆,但像修改资料之类的功能就不行了,只得再申请一个。

以下仅仅是记录一下我的生活,

P1.

昨天终于把sql server装好了,虽然由05换到了2000,但至少目前能打开c#编的动态网站了。

原先装05时只找到了express版的,连个企业管理器都没有,后来从微软的站点down了个,数据库导入了,但网站仍旧打不开,在百度上搜了n久,也尝试了许多办法,还是不行,只得换到2000。

下面简单记录一下安装ss2000的过程:

1.安装向导启动后点下一步,在选择计算机(本地,远程,虚拟)里选择本地,下一步,弹出一个对话框,内容为:  "以前的某个程序安装已在安装计算机上创建挂起的文件操作.运行安装程序之前必须重新启动计算机",重新启动后,再按以上步骤开始,问题依旧.

解决方法:删除HKEY_local_MACHINE\system\current controlset\control\session manager中的pending file Renameoperations,问题解决。

2,如下图,

再编辑注册属性中,选使用windows身份验证

再进入属性选项中的安全性选项,在身份验证中选sql server和windows

然后重启一下服务,就欧科啦!

现在已经能在本机上打开需要连接sql server的网站啦!(当然还有个前提,就是配只好iis)

P2.

昨天还顺带装了个Proteus的破解版,才发现这东西真是太好玩了,还能仿真arm7来跑uCos!呵呵,最近可有东西玩啦!

点击此处查看原文 >>

系统分类: 生活点滴   |    用户分类: 无分类    |    来源: 原创

评论(0) | 阅读(99)
总共 , 当前 /