目录

  • 效果
    • 乘方
  • 源码

版本:Grey Hack v0.7.3619 - Alpha


在Gs中,位数大于15的整数将以科学计数法显示,故这里提供一种基于字符串加法的四则大数运算算法。由于位数大于10的字符串无法用to_int方法转化为整数,因此本示例中以长度9分割字符串以加速计算。

效果

乘方


对照:

源码

add = function(Str0, Str1)Str0 = Str0.trimStr1 = Str1.trimif Str0[0] == "+" or Str0[0] == "-" thenStrNum0 = Str0[1:]elseStrNum0 = Str0[0:]end if while StrNum0[0] == "0" and len(StrNum0) > 1StrNum0 = StrNum0[1:]end whileLen0 = len(StrNum0)if Str1[0] == "+" or Str1[0] == "-" thenStrNum1 = Str1[1:]elseStrNum1 = Str1[0:]end ifwhile StrNum1[0] == "0" and len(StrNum1) > 1StrNum1 = StrNum1[1:]end whileLen1 = len(StrNum1)if Str0[0] == "-" then Sign0 = "-"elseSign0 = "+"end ifif Str1[0] == "-" then Sign1 = "-"elseSign1 = "+"end ifSign = ""if Len0 > Len1 thenSign = Sign0StrLonger = StrNum0[0:]StrSmaller = StrNum1[0:]else if Len0 < Len1 thenSign = Sign1StrLonger = StrNum1[0:]StrSmaller = StrNum0[0:]elsefor _ in range(0, Len0 - 1, 1)if StrNum0[_].to_int > StrNum1[_].to_int thenSign = Sign0StrLonger = StrNum0[0:]StrSmaller = StrNum1[0:]else if StrNum0[_].to_int < StrNum1[_].to_int thenSign = Sign1StrLonger = StrNum1[0:]StrSmaller = StrNum0[0:]end ifif Sign != "" then breakend forend ifif Sign == "" then Sign = Sign0StrLonger = StrNum0[0:]StrSmaller = StrNum1[0:]end ifStrLongerList = [] while len(StrLonger) > 9StrLongerList = StrLongerList + [StrLonger[-9:]]StrLonger = StrLonger[:-9]end whileif StrLonger != "" then StrLongerList = StrLongerList + [StrLonger]StrSmallerList = [] while len(StrSmaller) > 9StrSmallerList = StrSmallerList + [StrSmaller[-9:]]StrSmaller = StrSmaller[:-9]end whileif StrSmaller != "" then StrSmallerList = StrSmallerList + [StrSmaller]ResultStr = ""if Sign0 == Sign1 then Jinwei = 0for _ in range(0, len(StrSmallerList) - 1, 1)temp = Jinwei + StrLongerList[_].to_int + StrSmallerList[_].to_intif temp >= 1000000000 thentemp = temp - 1000000000Jinwei = 1elseJinwei = 0end iftemp = str(temp)while len(temp) < 9temp = "0" + tempend whileResultStr = temp + ResultStrend forif len(StrLongerList) != len(StrSmallerList) thenfor _ in range(len(StrSmallerList), len(StrLongerList) - 1, 1)temp = Jinwei + StrLongerList[_].to_intif temp >= 1000000000 thentemp = temp - 1000000000Jinwei = 1elseJinwei = 0end iftemp = str(temp)while len(temp) < 9temp = "0" + tempend whileResultStr = temp + ResultStrend forend ifif Jinwei == 1 thenResultStr = "1" + ResultStrJinwei = 0end ifelseJiewei = 0for _ in range(0, len(StrSmallerList) - 1, 1)temp = Jiewei + StrLongerList[_].to_int - StrSmallerList[_].to_intif temp < 0 thentemp = temp + 1000000000Jiewei = -1elseJiewei = 0end iftemp = str(temp)while len(temp) < 9temp = "0" + tempend whileResultStr = temp + ResultStrend forif len(StrLongerList) != len(StrSmallerList) thenfor _ in range(len(StrSmallerList), len(StrLongerList) - 1, 1)temp = Jiewei + StrLongerList[_].to_intif temp < 0 thentemp = temp + 1000000000Jiewei = -1elseJiewei = 0end iftemp = str(temp)while len(temp) < 9temp = "0" + tempend whileResultStr = temp + ResultStrend forend ifend ifwhile ResultStr[0] == "0" and len(ResultStr) > 1ResultStr = ResultStr[1:]end whileResultStr = Sign + ResultStrif len(ResultStr) == 2 and ResultStr[1] == "0" thenreturn "0"elsereturn ResultStrend if
end functionsub = function(Str0, Str1)Str0 = Str0.trimStr1 = Str1.trimif Str0[0] == "+" or Str0[0] == "-" thenStrNum0 = Str0[1:]elseStrNum0 = Str0[0:]end if while StrNum0[0] == "0" and len(StrNum0) > 1StrNum0 = StrNum0[1:]end whileif Str1[0] == "+" or Str1[0] == "-" thenStrNum1 = Str1[1:]elseStrNum1 = Str1[0:]end ifwhile StrNum1[0] == "0" and len(StrNum1) > 1StrNum1 = StrNum1[1:]end whileif Str0[0] == "-" then Sign0 = "-"elseSign0 = "+"end ifif Str1[0] == "-" then Sign1 = "+"elseSign1 = "-"end ifreturn add(Sign0 + StrNum0, Sign1 + StrNum1)
end functionmul = function(Str0, Str1)Str0 = Str0.trimStr1 = Str1.trimif Str0[0] == "+" or Str0[0] == "-" thenStrNum0 = Str0[1:]elseStrNum0 = Str0[0:]end if while StrNum0[0] == "0" and len(StrNum0) > 1StrNum0 = StrNum0[1:]end whileLen0 = len(StrNum0)if Str1[0] == "+" or Str1[0] == "-" thenStrNum1 = Str1[1:]elseStrNum1 = Str1[0:]end ifwhile StrNum1[0] == "0" and len(StrNum1) > 1StrNum1 = StrNum1[1:]end whileLen1 = len(StrNum1)if StrNum0 == "0" or StrNum1 == "0" then return "0"if Str0[0] == "-" then Sign0 = "-"elseSign0 = "+"end ifif Str1[0] == "-" then Sign1 = "-"elseSign1 = "+"end ifSign = ""if Len0 > Len1 thenSign = Sign0StrLonger = StrNum0[0:]StrSmaller = StrNum1[0:]else if Len0 < Len1 thenSign = Sign1StrLonger = StrNum1[0:]StrSmaller = StrNum0[0:]elsefor _ in range(0, Len0 - 1, 1)if StrNum0[_].to_int > StrNum1[_].to_int thenSign = Sign0StrLonger = StrNum0[0:]StrSmaller = StrNum1[0:]else if StrNum0[_].to_int < StrNum1[_].to_int thenSign = Sign1StrLonger = StrNum1[0:]StrSmaller = StrNum0[0:]end ifif Sign != "" then breakend forend ifif Sign == "" then Sign = Sign0StrLonger = StrNum0[0:]StrSmaller = StrNum1[0:]end ifif Sign0 == Sign1 thenSign = "+"elseSign = "-"end ifResultStr = "0"while StrSmaller != "0"StrSmaller = add(StrSmaller, "-1")ResultStr = add(ResultStr, StrLonger)end whilereturn (Sign + ResultStr[1:])
end functiondiv = function(Str0, Str1)Str0 = Str0.trimStr1 = Str1.trimif Str0[0] == "+" or Str0[0] == "-" thenStrNum0 = Str0[1:]elseStrNum0 = Str0[0:]end if while StrNum0[0] == "0" and len(StrNum0) > 1StrNum0 = StrNum0[1:]end whileif Str1[0] == "+" or Str1[0] == "-" thenStrNum1 = Str1[1:]elseStrNum1 = Str1[0:]end ifwhile StrNum1[0] == "0" and len(StrNum1) > 1StrNum1 = StrNum1[1:]end whileif StrNum1 == "0" then exit("Runtime error: divide by zero")if StrNum0 == "0" then return ["0", "0"]if Str0[0] == "-" then Sign0 = "-"elseSign0 = "+"end ifif Str1[0] == "-" then Sign1 = "-"elseSign1 = "+"end ifif Sign0 == Sign1 thenSign = "+"elseSign = "-"end ifResultStr = "0"TempStr = sub(StrNum0, StrNum1)while TempStr[0] != "-" StrNum0 = TempStrTempStr = sub(StrNum0, StrNum1)ResultStr = add(ResultStr, "1")end whileif ResultStr[0] == "+" then ResultStr = Sign + ResultStr[1:]end ifif StrNum0[0] == "+" then StrNum0 = Sign0 + StrNum0[1:]end ifreturn [ResultStr, StrNum0]
end functionpow = function(Str0, Str1)Str0 = Str0.trimStr1 = Str1.trimif Str0[0] == "+" or Str0[0] == "-" thenStrNum0 = Str0[1:]elseStrNum0 = Str0[0:]end if while StrNum0[0] == "0" and len(StrNum0) > 1StrNum0 = StrNum0[1:]end whileif Str1[0] == "+" or Str1[0] == "-" thenStrNum1 = Str1[1:]elseStrNum1 = Str1[0:]end ifwhile StrNum1[0] == "0" and len(StrNum1) > 1StrNum1 = StrNum1[1:]end whileif StrNum1 == "0" then return "+1"if StrNum0 == "0" then return "0"if Str0[0] == "-" then Sign0 = "-"elseSign0 = "+"end ifif Str1[0] == "-" then Sign1 = "-"elseSign1 = "+"end ifResultStr = "1"while StrNum1 != "0"ResultStr = mul(ResultStr, Sign0 + StrNum0)StrNum1 = add(StrNum1, "-1")end whilereturn ResultStr
end function// print(add(params[0],params[1]))
// print(sub(params[0],params[1]))
// print(mul(params[0],params[1]))
// print(div(params[0],params[1]))
// print(pow(params[0],params[1]))

【 Grey Hack 】大数四则运算相关推荐

  1. 【 Grey Hack 】综合工具 shellOs

    目录 交互界面 基本功能 本地攻击 攻击本机 远程攻击 应用程序 扫描功能 更新IP并扫描 深度扫描 黑入功能 类shell交互界面 一些特殊命令 bounce run ScanPsw vim bui ...

  2. 【 Grey Hack 】WIFI万能钥匙

    目录 脚本源码 使用方法 效果 版本:Grey Hack v0.7.3618 - Alpha 脚本源码 computer = get_shell.host_computer status = &quo ...

  3. 【 Grey Hack 】加强版nmap

    目录 probe 使用方法 效果 routerpcscan 使用方法 效果 版本:Grey Hack v0.7.3618 - Alpha probe if params.len != 1 or par ...

  4. 【 Grey Hack 】记一次被黑经历

    目录 又被搞了 版本:Grey Hack v0.7.3618 - Alpha 胆大包天的我黑进游戏内shop的IP后,顺着其上面的日志溯源到不少疑似其他玩家租的服务器,暂时没什么进展 不久后回到桌面才 ...

  5. 【 Grey Hack 】万金油脚本:常见端口修改Password

    目录 脚本源码 用法 效果及示例 版本:Grey Hack v0.7.3618 - Alpha 适用于SSH (22) 端口.FTP (21) 端口.HTTP (80) 端口.SMTP (25) 端口 ...

  6. 【 Grey Hack 】万金油脚本:原地提权工具

    目录 脚本源码 用法 效果及示例 版本:Grey Hack v0.7.3618 - Alpha 脚本源码 metaxploit = include_lib("/lib/metaxploit. ...

  7. 【 Grey Hack 】反向Shell

    目录 调查 准备反向shell 反向shell 提权 版本:Grey Hack v0.7.3618 - Alpha 如图,本案例中目标IP尚未开放常见端口 调查 通过路由器获得目标PC的用户邮箱账号和 ...

  8. 【 Grey Hack 】万金油脚本:在路由器上获取shell

    目录 脚本源码 用法 效果及示例 版本:Grey Hack v0.7.3618 - Alpha 脚本源码 if params.len != 2 or params[0] == "-h&quo ...

  9. 【 Grey Hack 】万金油脚本:从路由器获取Password

    目录 脚本源码 用法 效果及示例 版本:Grey Hack v0.7.3618 - Alpha 脚本源码 if params.len != 2 or params[0] == "-h&quo ...

最新文章

  1. Python一维二维数据的格式化和处理
  2. [C++]键盘钩子程序
  3. [jstips]向数组中插入一个元素
  4. 模板:树上启发式合并(dsu on tree)
  5. 系统间数据传输,产品经理视角的9千字总结:接口、otter、log4j、SFTP、MQ……
  6. MSP430F5529 DriverLib 库函数学习笔记(七)定时器B
  7. 安装好grunt,cmd 提示grunt不是内部或外部命令 怎么办?
  8. maven实战之我见一(maven初识)
  9. 计算机组成原理 - x86 x64 arm64的区别 - 学习/实践
  10. 我是游戏设计师——《游戏设计艺术》
  11. win7IE10和win7IE11浏览器更新所需补丁全套【附安装流程】
  12. Windows下Tomcat8的安装和闪退问题解决
  13. 2. webpack 处理 css less sass scss styl 资源
  14. STM32 MDK片外FLASH下载算法制作 —— 基于QSPI(W25Q32)
  15. 二叉搜索树的删除操作详解,图文并茂,化繁为简
  16. 对于拉格朗日乘数法的个人理解
  17. 基于粒子群算法和遗传算法优化的高速列车横向悬挂模糊PID控制
  18. 《一个64位操作系统的设计与实现》学习实践3-boot加载loader
  19. lab值意义_色差仪lab值含义是什么?
  20. 一口气笑穿极简印度史,简到崩溃,笑到流泪(一)

热门文章

  1. (原)用pixi.js 实现 方块阵点击后原地自转效果
  2. PHP笔记——java程序员看懂PHP程序
  3. ESXI忘记密码怎么办?
  4. 机器学习实践三---神经网络学习
  5. Tensorflow框架:InceptionV3网络概念及实现
  6. 重学TCP协议(11)TFO(Tcp Fast Open)
  7. leetcode226. 翻转二叉树(dfs)
  8. css flexbox模型_如何将Flexbox后备添加到CSS网格
  9. Command Magicks:如何使用控制台处理文件和字符串
  10. 科大讯飞 ai算法挑战赛_为井字游戏挑战构建AI算法