| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 624 人关注过本帖
标题:大哥们,帮我看一段程序吧
只看楼主 加入收藏
lhlbeer
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-9-9
收藏
 问题点数:0 回复次数:0 
大哥们,帮我看一段程序吧

求救下面一段程序的算法是什么,我看不懂呀。 PROCEDURE DecToBin

PARAMETER INNUM

OUTSTR = SPACE(0)

DO WHILE INNUM > 0

OUTSTR = STR(MOD(INNUM,2),1,0) + OUTSTR

INNUM = INT(INNUM / 2)

ENDDO

RETURN (OUTSTR)

ENDPROC

*------

PROCEDURE BinToDec

PARAMETER INSTR

PRIVATE ALL LIKE j*

JNLEN = LEN(ALLTRIM(INSTR))

JNSUM = 0

FOR NCTR = 0 TO JNLEN

IF SUBSTR(INSTR,JNLEN - NCTR,1) = '1'

JNSUM = JNSUM + (2 ** NCTR)

ENDIF

ENDFOR

RETURN (JNSUM)

ENDPROC

*------

PROCEDURE DecToHex

PARAMETER INNUM

OUTSTR = SPACE(0)

DO WHILE INNUM > 0

OUTSTR = FINDHEX(MOD(INNUM,16)) + OUTSTR

INNUM = INT(INNUM / 16)

ENDDO

RETURN (OUTSTR)

ENDPROC

*------

PROCEDURE FindHex

PARAMETER INVAL

PRIVATE ALL LIKE j*

DO CASE

CASE INVAL = 10

JOUTSTR = 'A'

CASE INVAL = 11

JOUTSTR = 'B'

CASE INVAL = 12

JOUTSTR = 'C'

CASE INVAL = 13

JOUTSTR = 'D'

CASE INVAL = 14

JOUTSTR = 'E'

CASE INVAL = 15

JOUTSTR = 'F'

OTHERWISE

JOUTSTR = STR(INVAL,1,0)

ENDCASE

RETURN (JOUTSTR)

ENDPROC

*------

PROCEDURE HexToDec

PARAMETER INSTR

PRIVATE ALL LIKE J*

INSTR = ALLTRIM(INSTR)

JLEN = LEN(INSTR)

NSUM = 0

RPTR = 0

FOR NCTR = 1 TO JLEN

CPTR = UPPER(SUBSTR(INSTR,JLEN - RPTR,1))

DO CASE

CASE CPTR = 'A'

CPTR = '10'

CASE CPTR = 'B'

CPTR = '11'

CASE CPTR = 'C'

CPTR = '12'

CASE CPTR = 'D'

CPTR = '13'

CASE CPTR = 'E'

CPTR = '14'

CASE CPTR = 'F'

CPTR = '15'

ENDCASE

NSUM = NSUM + (VAL(CPTR) * 16 ** (NCTR - 1))

RPTR = RPTR + 1

ENDFOR

RETURN (NSUM)

ENDPROC

*------

PROCEDURE fillstr

PARAMETER CCODE1 , INNUM

A1 = '000000000000000000000000'

CCODE1 = ALLTRIM(CCODE1)

A1 = SUBSTR(A1,1,B1)

CCODE1 = A1 + CCODE1

RETURN (CCODE1)

ENDPROC

搜索更多相关主题的帖子: 大哥 
2005-09-09 22:33
快速回复:大哥们,帮我看一段程序吧
数据加载中...
 
   



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

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