分批计算余数? [英] Calculating remainder in batch?

查看:79
本文介绍了分批计算余数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在手动输入到命令提示符时,以下顺序将按需工作:

When entered manually into the commnand prompt, the following sequence works as desired:

>set /a r=3%2
1
>echo %r%
1

但是,从批处理文件启动时却没有,因为%2显然具有不同的含义.

However, when launched from batchh file, it doesn't, as %2 clearly has a different meaning.

>set /a r=3%2

>echo %r%
3

如何使批处理文件像在第一个示例中那样处理其余部分? 有问题的系统是XP.

How do I make the batch file do what I did in the first example, claculating the remainder? The system in question is XP.

推荐答案

在批处理文件中使用以下语法:

use this syntax in batch-files:

set /a "r=3 %% 2"

这篇关于分批计算余数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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