您的位置:程序门 -> vb -> 基础类



郁闷!写的一个小模块,给老板骂了一通,说水平太低! 大家有什么地方可改


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


郁闷!写的一个小模块,给老板骂了一通,说水平太低! 大家有什么地方可改
发表于:2007-03-09 12:02:13 楼主
private   sub   form_load()

nummesh   =   11

dim   n   as   integer
n   =   nummesh
redim   mesh_id(n)
redim   mesh_pid(n)
redim   mesh_gid(n)

redim   plane(n)

   

        mesh_id(1)   =   "11 "
        mesh_pid(1)   =   "1 "
        mesh_gid(1)   =   "2 "

        mesh_id(2)   =   "12 "
        mesh_pid(2)   =   "2 "
        mesh_gid(2)   =   "3 "
       
        mesh_id(3)   =   "13 "
        mesh_pid(3)   =   "4 "
        mesh_gid(3)   =   "5 "
       
        mesh_id(4)   =   "14 "
        mesh_pid(4)   =   "6 "
        mesh_gid(4)   =   "7 "
       
       
        mesh_id(5)   =   "15 "
        mesh_pid(5)   =   "8 "
        mesh_gid(5)   =   "9 "
       
       
        mesh_id(6)   =   "16 "
        mesh_pid(6)   =   "9 "
        mesh_gid(6)   =   "10 "
       
        mesh_id(7)   =   "17 "
        mesh_pid(7)   =   "11 "
        mesh_gid(7)   =   "12 "
       
        mesh_id(8)   =   "18 "
        mesh_pid(8)   =   "5 "
        mesh_gid(8)   =   "13 "
       
       
        mesh_id(9)   =   "19 "
        mesh_pid(9)   =   "14 "
        mesh_gid(9)   =   "15 "
       
        mesh_id(10)   =   "20 "
        mesh_pid(10)   =   "13 "
        mesh_gid(10)   =   "16 "
       
        mesh_id(11)   =   "21 "
        mesh_pid(11)   =   "17 "
        mesh_gid(11)   =   "18 "


dim   planenum   as   integer


plane(1)   =   mesh_pid(1)   &   "* "   &   mesh_gid(1)   &   "* "

for   i   =   2   to   n


        for   k   =   1   to   n
               
             
                if   i   >   k   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   =   0   then
                        plane(k)   =   plane(k)   &   mesh_gid(i)   &   "* "
                   
                        k   =   n
               
                elseif   i   >   k   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   =   0   then
                        plane(k)   =   plane(k)   &   mesh_pid(i)   &   "* "
                     
                        k   =   n
               
                elseif   i   >   k   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   =   0   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   =   0   then
               
                        if   plane(k   +   1)   =   empty   then
                               
                                x   =   0
                                for   q   =   1   to   k
                                               
                                        if   instr(1,   plane(q),   mesh_gid(i)   &   "* ",   0)   =   0   and   instr(1,   plane(q),   mesh_gid(i)   &   "* ",   0)   =   0   then
                                       
                                                x   =   x   +   1
                                       
               
                                        end   if
                                       
                                     
                                next
                               
                                        if   x   =   k   then
                                       
                                                plane(k   +   1)   =   mesh_pid(i)   &   "* "   &   mesh_gid(i)   &   "* "
                                                planenum   =   k   +   1
                                       
                                        end   if
                                       
                               
                        end   if
               
               
                end   if
               
               
        next
   

next

debug.print   "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ "
debug.print   "********************************* "
debug.print   "! "   &   planenum

for   j   =   1   to   planenum

      debug.print   plane(j)
     
   
next


debug.print   "********************************* "
debug.print   "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ "


end   sub

发表于:2007-03-09 12:07:161楼 得分:0
其实完成的功能很简单

就是遍历这些mesh,放到不同的平面上

输出结果是:

!7
1*2*3*
4*5*13*16*
6*7*
8*9*10*
11*12*
14*15*
17*18*


大家不知道有什么好的算法 万分感谢
发表于:2007-03-09 12:28:192楼 得分:0
请在窗体代码最前处声明变量
option   explicit
dim   i   as   integer
dim   j   as   integer
dim   k   as   integer
dim   x   as   integer
dim   q   as   integer
dim   nummesh   as   integer
dim   mesh_id()   as   string
dim   mesh_pid()   as   string
dim   mesh_gid()   as   string
dim   plane()   as   string
dim   n   as   integer

private   sub   form_load()
n   =   inputbox( "输入n= ")
redim   mesh_id(n)
redim   mesh_pid(n)
redim   mesh_gid(n)
redim   plane(n)
        mesh_id(1)   =   "11 "
        mesh_pid(1)   =   "1 "
        mesh_gid(1)   =   "2 "

        mesh_id(2)   =   "12 "
        mesh_pid(2)   =   "2 "
        mesh_gid(2)   =   "3 "
       
        mesh_id(3)   =   "13 "
        mesh_pid(3)   =   "4 "
        mesh_gid(3)   =   "5 "
       
        mesh_id(4)   =   "14 "
        mesh_pid(4)   =   "6 "
        mesh_gid(4)   =   "7 "
       
       
        mesh_id(5)   =   "15 "
        mesh_pid(5)   =   "8 "
        mesh_gid(5)   =   "9 "
       
       
        mesh_id(6)   =   "16 "
        mesh_pid(6)   =   "9 "
        mesh_gid(6)   =   "10 "
       
        mesh_id(7)   =   "17 "
        mesh_pid(7)   =   "11 "
        mesh_gid(7)   =   "12 "
       
        mesh_id(8)   =   "18 "
        mesh_pid(8)   =   "5 "
        mesh_gid(8)   =   "13 "
       
        mesh_id(9)   =   "19 "
        mesh_pid(9)   =   "14 "
        mesh_gid(9)   =   "15 "
       
        mesh_id(10)   =   "20 "
        mesh_pid(10)   =   "13 "
        mesh_gid(10)   =   "16 "
       
        mesh_id(11)   =   "21 "
        mesh_pid(11)   =   "17 "
        mesh_gid(11)   =   "18 "

dim   planenum   as   integer
plane(1)   =   mesh_pid(1)   &   "* "   &   mesh_gid(1)   &   "* "
for   i   =   2   to   n
        for   k   =   1   to   n
                if   i   >   k   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   =   0   then
                        plane(k)   =   plane(k)   &   mesh_gid(i)   &   "* "
                        k   =   n
                elseif   i   >   k   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   =   0   then
                        plane(k)   =   plane(k)   &   mesh_pid(i)   &   "* "
                        k   =   n
                elseif   i   >   k   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   =   0   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   =   0   then
                        if   plane(k   +   1)   =   empty   then
                                x   =   0
                                for   q   =   1   to   k
                                        if   instr(1,   plane(q),   mesh_gid(i)   &   "* ",   0)   =   0   and   instr(1,   plane(q),   mesh_gid(i)   &   "* ",   0)   =   0   then
                                                x   =   x   +   1
                                        end   if
                                next
                                        if   x   =   k   then
                                                plane(k   +   1)   =   mesh_pid(i)   &   "* "   &   mesh_gid(i)   &   "* "
                                                planenum   =   k   +   1
                                        end   if
                        end   if
                end   if
        next
next
debug.print   "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ "
debug.print   "********************************* "
debug.print   "! "   &   planenum
for   j   =   1   to   planenum
      debug.print   plane(j)
next
debug.print   "********************************* "
debug.print   "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ "
end   sub
发表于:2007-03-09 12:32:593楼 得分:0
谢谢楼上 可关键问题是算法阿

老板说算法太复杂

有没有办法减少复杂度?
发表于:2007-03-09 13:01:354楼 得分:0
看了半天   不止到你在干什么
发表于:2007-03-09 13:45:205楼 得分:0
呵呵,同感
发表于:2007-03-09 14:09:576楼 得分:0
我也没看明白,希望楼主能稍加解释这段代码要实现的功能
发表于:2007-03-09 14:17:047楼 得分:0
我也看不明白,说明白些啊,把要求
发表于:2007-03-09 14:57:228楼 得分:0
没看懂
发表于:2007-03-09 16:14:139楼 得分:0
确实写得不怎么样   不想看
发表于:2007-03-09 20:17:3510楼 得分:0
不知道是干什么,非要   这么麻烦,你能把题目说清楚么?
发表于:2007-03-09 20:50:2111楼 得分:0
没看懂
发表于:2007-03-09 23:59:1312楼 得分:0
看了半天
发表于:2007-03-10 00:15:5513楼 得分:0
mesh   里面有2个值,“1,2 "   或者  "3,4 "   ......

先把第一个mesh里面的值   1   和 2   放到一个数组plane()

初始化   plane(1)   =     "1*2* "     // *   是为了字符串比较区别 11   和 1   这样的数

      mesh_id(1)   =   "11 "
      mesh_pid(1)   =   "1 "
      mesh_gid(1)   =   "2 "    

每一个mesh   里面的值可能有和前面mesh   里面的值相同的,比如说 
     
     

        mesh_id(2)   =   "12 "
        mesh_pid(2)   =   "2 "
        mesh_gid(2)   =   "3 "  

或者

  mesh_id(2)   =   "12 "
        mesh_pid(2)   =   "3 "
        mesh_gid(2)   =   "2 "

要做的就是如果前面有一个相同的 mesh_pid()或者 mesh_gid()   在前面的mesh   里面, 就把这个mesh   里面的另外一个不相同加入到已经构造好的plane()

plane(1)   =     "1*2*3 "

如果找不到相同的就 新建一个plane()
       
        mesh_id(2)   =   "13 "
        mesh_pid(2)   =   "4 "
        mesh_gid(2)   =   "5 "

plane(2)   =   "4*5* "

程序完成的功能就是遍历所以这些mesh,查找相同在合并到plane()   或者新建 plane().


希望大家能明白


发表于:2007-03-10 00:23:0814楼 得分:0
看了一眼没明白,不过感觉就是字符操作,应该有更简单的算法

现在对长篇的东西没心情看下去,郁闷
发表于:2007-03-10 09:04:1615楼 得分:0
看了遍楼主的解释     还是没有明白   看来我的理解有问题
发表于:2007-03-10 09:21:2716楼 得分:0
更新了一下程序 大家看看怎么样

dim   planenum   as   integer

plane(1)   =   mesh_pid(1)   &   "* "   &   mesh_gid(1)   &   "* "

for   i   =   2   to   n


        for   k   =   1   to   i
               
             
                if   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   =   0   then
                       
                        plane(k)   =   plane(k)   &   mesh_gid(i)   &   "* "
                   
                        goto   new_mesh
               
                elseif   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   =   0   then
                       
                        plane(k)   =   plane(k)   &   mesh_pid(i)   &   "* "
                     
                        goto   new_mesh
               
                elseif   i   >   k   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   =   0   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   =   0   then
               
       
                              if   plane(k   +   1)   =   empty   and   plane(k)   <>   empty   then   '   plane(k)   can 't   be   empty
                   

                                      plane(k   +   1)   =   mesh_pid(i)   &   "* "   &   mesh_gid(i)   &   "* "
                                      planenum   =   k   +   1
                                               
                              end   if
               
                end   if

        next
   
new_mesh:

next
发表于:2007-03-10 09:58:1717楼 得分:0

哇噻好复杂哦。     看了好几遍说明也没看明白到底是要干什么呢。
发表于:2007-03-10 10:15:3818楼 得分:0
樓主強
不過我想現在的人一般都懶了
不是一下子看不懂的東東,是不會怎么去看了的
所以應該不是人家看不懂
是要很費勁的去懂

我們都不是天才
樓主理解萬歲
发表于:2007-03-10 11:48:0419楼 得分:0
还是没有完全明白楼主的确切要求
不过看起来楼主第二次的代码应该可以了
goto   new_mesh可以换成exit   for
不然老板看到你用goto可能又要骂了
发表于:2007-03-10 11:49:1720楼 得分:0
option   explicit

sub   runplacement(pid   as   variant,   gid   as   variant,   byref   icount   as   long,   byref   result   as   variant)
        dim   inumber   as   long,   iloop   as   long,   ifind   as   long,   bfind   as   boolean
        dim   stemp   as   string,   itemp   as   long
        inumber   =   ubound(pid)
        redim   result(inumber)
        icount   =   0
        for   iloop   =   1   to   inumber
                bfind   =   false
                for   ifind   =   1   to   icount
                        itemp   =   instrrev(result(ifind),   "* ")
                        if   itemp   >   0   then
                                stemp   =   mid(result(ifind),   itemp   +   1)
                                if   stemp   =   pid(iloop)   then
                                        bfind   =   true
                                        exit   for
                                end   if
                        end   if
                next   ifind
                if   bfind   then
                        result(ifind)   =   result(ifind)   &   "* "   &   gid(iloop)
                else
                        icount   =   icount   +   1
                        result(icount)   =   pid(iloop)   &   "* "   &   gid(iloop)
                end   if
        next   iloop
        redim   preserve   result(icount)
        for   iloop   =   1   to   icount
                result(iloop)   =   result(iloop)   &   "* "
        next   iloop
end   sub

private   sub   form_load()
        dim   mesh_id(11)   as   string
        dim   mesh_pid(11)   as   string
        dim   mesh_gid(11)   as   string
       
        mesh_id(1)   =   "11 "
        mesh_pid(1)   =   "1 "
        mesh_gid(1)   =   "2 "
       
        mesh_id(2)   =   "12 "
        mesh_pid(2)   =   "2 "
        mesh_gid(2)   =   "3 "
       
        mesh_id(3)   =   "13 "
        mesh_pid(3)   =   "4 "
        mesh_gid(3)   =   "5 "
       
        mesh_id(4)   =   "14 "
        mesh_pid(4)   =   "6 "
        mesh_gid(4)   =   "7 "
       
       
        mesh_id(5)   =   "15 "
        mesh_pid(5)   =   "8 "
        mesh_gid(5)   =   "9 "
       
       
        mesh_id(6)   =   "16 "
        mesh_pid(6)   =   "9 "
        mesh_gid(6)   =   "10 "
       
        mesh_id(7)   =   "17 "
        mesh_pid(7)   =   "11 "
        mesh_gid(7)   =   "12 "
       
        mesh_id(8)   =   "18 "
        mesh_pid(8)   =   "5 "
        mesh_gid(8)   =   "13 "
       
       
        mesh_id(9)   =   "19 "
        mesh_pid(9)   =   "14 "
        mesh_gid(9)   =   "15 "
       
        mesh_id(10)   =   "20 "
        mesh_pid(10)   =   "13 "
        mesh_gid(10)   =   "16 "
       
        mesh_id(11)   =   "21 "
        mesh_pid(11)   =   "17 "
        mesh_gid(11)   =   "18 "
       
        dim   iloop   as   long
        dim   icount   as   long
        dim   result()   as   string
        runplacement   mesh_pid,   mesh_gid,   icount,   result
        debug.print   "! "   &   icount
        for   iloop   =   1   to   icount
                debug.print   result(iloop)
        next   iloop
        end
end   sub
发表于:2007-03-10 11:51:3521楼 得分:0
runplacement是个处理楼主所描述的数据的通用函数。
调用它需要两个数组参数:   pid和gid
它返回两个结果值:   icount和result

楼主看来刚学编程不会太久,对问题的描述、数据结构的描述、算法的描述等各方面的能力,还需加强。
发表于:2007-03-10 12:08:1022楼 得分:0
up
发表于:2007-03-10 17:52:2123楼 得分:0
怎么   if   和   elseif的   内容完全一样的   你们老板不骂你才怪
                if   i   >   k   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   =   0   then
                        plane(k)   =   plane(k)   &   mesh_gid(i)   &   "* "
                   
                        k   =   n
               
        elseif   i   >   k   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   =   0   then
                        plane(k)   =   plane(k)   &   mesh_pid(i)   &   "* "
                     
                        k   =   n
发表于:2007-03-10 17:59:3024楼 得分:0
上面看错了   原来有个字符不一样~
for   i   =   2   to   n


        for   k   =   1   to   n
可以改为
for   i   =   2   to   n


        for   k   =   1   to   i-1
发表于:2007-03-10 18:23:2625楼 得分:0
总算看明白了点
楼主好像是要做个类似接龙的东西~~
发表于:2007-03-10 22:35:2926楼 得分:0
应该写一些注释会比较好
发表于:2007-03-11 10:39:2027楼 得分:0
该回复于2007-12-28 17:56:28被管理员或版主删除
发表于:2007-03-11 17:57:4028楼 得分:0
太麻烦了……
发表于:2007-03-11 18:41:3129楼 得分:0
老板会关心你的算法?

看来这个老板有来头
发表于:2007-03-11 22:43:2930楼 得分:0
没有看懂
发表于:2007-03-12 08:28:5131楼 得分:0
又改了改 大家看看怎么样


plane(1)   =   mesh_pid(1)   &   "* "   &   mesh_gid(1)   &   "* "

for   i   =   2   to   n   'search   all   the   mesh   from     mesh   two

        'search   all   the   plane   from     plane(1)     to   plane(k)   .   assume   :   the   mesh   number   =   plane   number
        for   k   =   1   to   i   -   1
   
                if   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   =   0   then
                       
                        plane(k)   =   plane(k)   &   mesh_gid(i)   &   "* "

                        exit   for   'once   find   mesh_pid   in   previous   plane   then   jump   out   of   loop   of   plane.

                elseif   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   <>   0   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   =   0   then
                       
                        plane(k)   =   plane(k)   &   mesh_pid(i)   &   "* "

                        exit   for     'once   find   mesh_gid   in   previous   plane   then   jump   out   of   loop   of   plane.

                '   plane(k)   can 't   be   empty   and   next   plane   should   be   empty
                elseif   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)   =   0   and   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)   =   0   and   plane(k)   <>   empty   and   plane(k   +   1)   =   empty   then
               
                        plane(k   +   1)   =   mesh_pid(i)   &   "* "   &   mesh_gid(i)   &   "* "
                        planenum   =   k   +   1

                end   if

        next
   

next
发表于:2007-03-12 09:04:2332楼 得分:0
把代码模块化,写成函数,并加上注释。

否则,这段代码在复用时,就麻烦了。
发表于:2007-03-12 09:14:0833楼 得分:0
这个我是知道

现在又有一个新问题 怎么画 for 语句的 流程图

是和if一样的吗 用菱形

发表于:2007-03-12 09:28:4634楼 得分:0
把你的目的说清楚,不要说你的做法。这样别人才会知道你要做什么。然后才会提建议。
发表于:2007-03-12 09:35:4235楼 得分:0
其实代码写的优劣,从一些基础点就能反应出来.
所以楼主想改良这段代码,从一些简单程序上练起也是一样会有收获.
关键是多看看代码规范和优化心得.
这是就整体而言,包括算法的实现细节(如果主要算法不改变的话).
如果要改变主要算法,那就是把楼推倒重建,不需要看你写的这些东西,要看需求.
楼主要改的话,也得把这些先甩一边,从纸上数学公式推导,重新考虑.
所以,楼主发的这个帖子本身就是矛盾的:是想让人就代码规范提建议,还是提供更好的算法?
发表于:2007-03-12 09:36:0836楼 得分:0
要多写注释
发表于:2007-03-12 10:06:0837楼 得分:0
11111
发表于:2007-03-12 17:14:2938楼 得分:0
请将你要做的事     写在   一个函数里面   ,你所做的每步操作都加上注释,那样大家才知道你做的事.流程图都是一样的,自己先了解自己要做什么,才能画出流程图.好怀念以前写vb的日子....
发表于:2007-03-12 17:15:3939楼 得分:0
忘记说了,对于那写重复操作的东西   可以写在模块里面^_^
发表于:2007-03-12 17:25:2740楼 得分:0
楼主的代码到现在仍然是一个垃圾代码,我不是说什么算法,而是你改到现在仍然没有看到你写一句注释
发表于:2007-03-13 11:18:0241楼 得分:0
又更新了一次


sub   findplane()

dim   i,   k,   found   as   integer
dim   pinion_check,   gear_check   as   integer

redim   plane(planenum)    

n   =   nummesh
'assign   the   pinion   and   gear   in   the   first   mesh   to   plane   1.
plane(1)   =   mesh_pid(1)   &   "* "   &   mesh_gid(1)   &   "* "
planenum   =   1

for   i   =   2   to   n   'search   all   the   mesh   from     mesh   two

found   =   0

        'search   all   the   plane   from     plane(1)     to   plane(k)   .   assume   :   the   mesh   number   =   plane   number
        for   k   =   1   to   planenum
               
              'compare   the   pinion   with   the   components   on   the   plane   k.
              check_mesh_pid   =   instr(1,   plane(k),   mesh_pid(i)   &   "* ",   0)
      'compare   the   gear   with   the   components   on   the   plane   k.
              check_mesh_gid   =   instr(1,   plane(k),   mesh_gid(i)   &   "* ",   0)

                if   check_mesh_pid   <>   0   and   check_mesh_gid   =   0   then     'if   the   pinion   is   already   on   the   plane   k   and   the   gear   is   not   on   the   plane   k,   assign   the   gear   to   the   plane   k.
                       
                        plane(k)   =   plane(k)   &   mesh_gid(i)   &   "* "
                        found   =   1
                        exit   for   'once   find   mesh_pid   in   previous   plane   then   jump   out   of   loop   of   plane.

                elseif   check_mesh_gid   <>   0   and   check_mesh_pid   =   0   then   'if   the   gear   is   already   on   the   plane   k   and   the   pinion   is   not   on   the   planek,   assign   the   pionion   to   the   plane   k.
                       
                        plane(k)   =   plane(k)   &   mesh_pid(i)   &   "* "
                        found   =   1
                        exit   for     'once   find   mesh_gid   in   previous   plane   then   jump   out   of   loop   of   plane.

                end   if

        next
                      if   found   =   0   then
                        'since   the   pinion   and   gear   are   not   on   plane   k,   a   new   plane   is   defined.
                        plane(planenum   +   1)   =   mesh_pid(i)   &   "* "   &   mesh_gid(i)   &   "* "   'assign   the   pinion   and   gear   to   the   new   plane.
                        planenum   =   planenum   +   1
                       
                      end   if
                                                     
next


'msgbox   planenum
end   sub
发表于:2007-03-13 11:23:0442楼 得分:0
不知道楼主有没有看我给你写的代码?
作为一个通用函数,应该避免在函数内直接引用全局变量。
你最后给出的代码,这个不能算是函数或子程序,还是会给老板骂的。
发表于:2007-03-13 12:36:0843楼 得分:0
redim   mesh_id(n)
redim   mesh_pid(n)
redim   mesh_gid(n)

这n都成摆设了......
发表于:2007-03-13 16:34:2344楼 得分:0
服了,我看你们老板不错了,只是骂了一通,没有打都不错了。
服了,我看你们老板不错了,只是骂了一通,没有打都不错了。
服了,我看你们老板不错了,只是骂了一通,没有打都不错了。
发表于:2007-03-14 10:30:5245楼 得分:0
回 jadeluo(秀峰)  

我这个程序很小 没有几个函数 我打算所有的函数都引用 全局变量

你写的代码我看了 很好 

您觉得我最后更新的程序 是最简练的吗? 和你的相比 
发表于:2007-03-15 08:23:0646楼 得分:0
有时候,   代码的可读性比简炼更为重要,   特别是在团队开发的时候。

你现在写的这段代码,如果是一个比较底层的函数,会被很多次调用的话,就得仔细考虑一下函数的参数问题,不要用全局变量。
发表于:2007-03-15 09:41:5547楼 得分:0
总之是越改越好了吧。


快速检索

最新资讯
热门点击