Variables 循环批处理-变量问题

Variables 循环批处理-变量问题,variables,batch-file,for-loop,modulus,Variables,Batch File,For Loop,Modulus,我必须在bash和batch中做一些事情。我被套圈零件的批次卡住了。我的部分作业说明如下: ::Doing a for loop from 1 to 100, :: - Find the results of calculating each number from 1 to 100 mod 5. :: - Append each number to the results.txt file :: - After the for loop ends calculate and display t

我必须在bash和batch中做一些事情。我被套圈零件的批次卡住了。我的部分作业说明如下:

::Doing a for loop from 1 to 100,
:: - Find the results of calculating each number from 1 to 100 mod 5.
:: - Append each number to the results.txt file
:: - After the for loop ends calculate and display the average of the results
:: - Append the average of the numbers to the results.txt file
::Code
:forLoop
echo.
::set /A temp-0
for /L %%x in (1, 1, 100) do (
    set /A result="%%x %% 5"
    call echo %%result%% >> results.txt 
    ::%%temp+=%%result%%
)
::average=temp/100
::append average
GOTO exit
其他用户帮助我使用结果变量和mod 5。然而,我目前在临时工方面遇到了麻烦。我认为,一旦我得到了临时工作,我应该能够让平均部分工作没有太多的问题。我的教授还提到批量中有3种不同类型的for循环,所以我甚至不确定是否使用了正确的for循环。谁能帮我解决这个问题

echo.
set /A temp=0
for /L %%x in (1, 1, 100) do (
    set /A result="%%x %% 5"
    call echo %%result%%  
    CALL SET /a temp+=%%result%%
)
SET /a average=temp/100
ECHO %average% %temp%
这很直截了当不要在块(括号内的一系列语句)中使用
注释样式,因为它实际上是一个断开循环的断开标签

除此之外,您还需要
调用
集合
,因为您没有使用
delayedexpansion
——因此需要将
%
s的常规数量翻倍——与
调用echo
相同

我已经取消了重定向,这样结果就会简单地显示在屏幕上