数字转化为时间分秒批处理脚本

问题描述 投票:0回答:1

我需要帮助让“目标时间”显示为分钟和秒,但我不知道如何。

@echo off
title torpedo calculator
:main

echo Menu:
echo 1.Torpedo Solution
echo 2.Exit
set /p ch=Enter your choice 

if %ch%==1 goto torp
if %ch%==2 goto exit


:torp
cls
set /p a=Range to target: 
set /p e=Bearing to target:  
set modify=700
set /a "c=%a%-%modify%""
set /a "d=%c%/43"
set /a "f=%a%/43"


cls
echo FIRING SOLUTION
echo Fire from the side the target is on
echo Activation = %d%
echo Bearing = %e%
echo Time to target = %f%
pause
goto main

:exit
timeout /t2
exit

在我发布的代码中 /a "f=%a%/43" 以秒为单位计算目标时间。 因此,例如,目标范围是 6700,目标时间是 155。我试图将该数字减去 60,但只得到 2 作为答案,没有小数点。我希望我已经解释过了,因为我是编码新手,所以它很有意义:D 非常感谢任何帮助。

batch-file
1个回答
0
投票
@echo off
title torpedo calculator
:main

echo Menu:
echo 1.Torpedo Solution
echo 2.Exit
set /p ch=Enter your choice 

if %ch%==1 goto torp
if %ch%==2 goto exit

:torp
cls
set /p a=Range to target: 
set /p e=Bearing to target:  
set modify=700
set /a "c=%a%-%modify%""
set /a "d=%c%/43"
set /a "f=%a%/43"
set /a "minutes=%f%/60"
set /a "seconds=%f%%%60"

cls
echo FIRING SOLUTION
echo Fire from the side the target is on
echo Activation = %d%
echo Bearing = %e%
echo Time to target = %minutes% minutes and %seconds% seconds
pause
goto main

:exit
timeout /t2
exit

© www.soinside.com 2019 - 2024. All rights reserved.