@echo off
title My Simple Calculator
echo What is the First Number you would like to Divide?
set /p number1=
echo What is the Second Number you would like to Divide?
set /p number2=
Set /A result = %number1% / %number2%
echo The answer is %result%.
pause
嗨。美好的一天。只是想问一些有关此问题的帮助。因为我对编程是“新手”。主题全部与CMD脚本有关。在我简单的计算器中,如何显示余数。预先谢谢你。
答案 0 :(得分:0)
根据我的评论以及在命令提示符下输入Set /?
时提供的信息,您可以将分组与乘法和减法算术运算符一起使用:
@Echo Off
Title My Simple Calculator
Set /P "number1=What is the number you would like to divide? "
Set /P "number2=What number would you like to divide %number1% by? "
Set /A result=number1/number2
Set /A remainder=number1-(result*number2)
Echo The answer is %result%, with a remainder of %remainder%.
Pause
或者,您也可以使用模数算术运算符%
,(如果在批处理文件中使用而不是在命令提示符下,则需要加倍):
@Echo Off
Title My Simple Calculator
Set /P "number1=What is the number you would like to divide? "
Set /P "number2=What number would you like to divide %number1% by? "
Set /A result=number1/number2
Set /A remainder=number1%%number2
Echo The answer is %result%, with a remainder of %remainder%.
Pause