在本地批处理中触发函数和平方根? [英] Trig functions and square root in native batch?

查看:87
本文介绍了在本地批处理中触发函数和平方根?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个工具,在整个过程中向用户显示此三角形:

I am making a tool where the user is shown this triangle throughout the process:

:draw
echo   ^|\
echo   ^|a\
echo   ^|  \
echo   ^|   \
echo   ^|    \ C
echo  A^|     \
echo   ^|      \
echo   ^|       \
echo   ^|c      b\
echo   ^|---------\
echo        B 
GOTO:EOF

任何字母在哪里,都有变量.首先,用户选择他们拥有的角度值.然后,他们选择一个边值.之后,所有值将自动填充.在我的源代码中,我只有sin(a)或类似的占位符,直到可以在本机批处理中找到触发函数(sin,cos,tan)和平方根为止.

Where any letters are, there are variables. First the users chooses which angle value they have. Then they choose a side value. After that, all of the values will automatically be filled in. In my source code I just have sin(a) or something similar as a placeholder until I can find the trig functions (sin, cos, tan) and squareroot in native batch.

代码: http://pastebin.com/bDfY84Vr

推荐答案

在此有效:

@echo off
echo what number do you want to get the sin cos and tan values from of?
set /p in=num:
for /f "delims=" %%a in (' powershell "[Math]::sin(%in%)" ') do set "sin=%%a"
echo the sin of %in% is %sin%
for /f "delims=" %%a in (' powershell "[Math]::cos(%in%)" ') do set "cos=%%a"
echo the cos of %in% is %cos%
for /f "delims=" %%a in (' powershell "[Math]::tan(%in%)" ') do set "tan=%%a"
echo the tan of %in% is %tan%
pause

这篇关于在本地批处理中触发函数和平方根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆