China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 00:35
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Discussion][Exploration] Using batch processing to make interesting math problems DigestI View 36,426 Replies 139
Floor 76 Posted 2006-11-21 23:38 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
I don't know if this meets the requirements:
@echo off
set c1=5
set c2=3
set/a pen=2*c2/(c1-c2)
set/a 温差=(pen+1)*c1
set/a 温升=(温差-c1-c2)/(pen+3)
echo There were originally %pen% cups of water, and the temperature difference between the water in the basin and the water in the cup was %温差% degrees.
echo Now the temperature rise is %温升% degrees.
pause
Floor 77 Posted 2006-11-21 23:58 ·  中国 江苏 苏州 联通
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
Completely correct
Floor 78 Posted 2006-11-22 02:03 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 79 Posted 2006-11-22 05:06 ·  IANA 局域网IP(Private-Use)
中级用户
★★
蝴蝶之吻
Credits 430
Posts 177
Joined 2006-09-20 12:00
19-year member
UID 63170
From 广东深圳
Status Offline
The problem has been updated
Floor 80 Posted 2006-11-22 07:17 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
First, the simplest 25, 26

25. "Chick and Rabbit in the Same Cage"

@echo off
setlocal enabledelayedexpansion

for /l %%i in (1 1 79) do (
set /a chick_num=%%i
set /a dog_num=79-!chick_num!
set /a footnum=2*!chick_num!+4*!dog_num!
if !footnum! EQU 200 (
set msg1=The number of chicks is:!chick_num!
set msg2=The number of dogs is:!dog_num!
goto :exit
)
)
:exit
echo %msg1%
echo %msg2%
pause>nul


26. The problem of big and small monks;

@echo off
setlocal enabledelayedexpansion

for /l %%i in (0 4 100) do (
set /a small=%%i/4
set /a big=400-%%i*4
set /a total=!small!+!big!
if !total! EQU 100 (
set msg1=The number of small monks is:%%i
set /a num=100-%%i
set msg2=The number of big monks is:!num!
goto :exit
)
)

:exit
echo %msg1%
echo %msg2%

pause>nul
Floor 81 Posted 2006-11-22 07:40 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
Question 23, the problem of weighing beads, should discard the "lucky" situation, if I am lucky, maybe I can do it in two times! ^--^

@echo off
setlocal enabledelayedexpansion
set flag=1
call :test 243
echo At least should be: %flag% times

pause>nul

:test
set /a tmp=%1 %% 2
set /a num=%1
if %tmp% NEQ 0 set /a num-=1
if %num% geq 2 (
set /a num/=2
set /a flag+=1
call :test !num!)
goto :eof
Floor 82 Posted 2006-11-23 07:09 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
I'll also post two questions:

1. Find prime numbers (with relatively high efficiency requirements)
2. Find the numbers within 1-49 such that the product of any two numbers is equal, for example: 2*3=6 and 1*6=6
Floor 83 Posted 2006-11-25 03:04 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Looking forward~ ~ Must not let a good post sink~ :)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 84 Posted 2006-11-25 06:57 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Find prime numbers within 10000

@echo off
setlocal enabledelayedexpansion
echo Prime numbers within 10000 are:
set/p a= 2 3 5 7 <nul
for /l %%a in (9 2 99) do (set/a a=%%a%%3
set/a b=%%a%%5
set/a c=%%a%%7
if not !a!==0 if not !b!==0 if not !c!==0 set/p a=%%a <nul)
for /l %%a in (101 2 9999) do (for /l %%b in (3 2 97) do (set/a a=%%a%%%%b
if !a!==0 set b=1)
if not !b!==1 set/p a=%%a <nul
set b=0)
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
youxi01 +2 2006-11-25 12:00
Floor 85 Posted 2006-11-25 07:03 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Question 24:
```
@echo off
:1
set/a a+=3
set/a b+=1
if not %a%==9 goto 1
echo This frog needs to jump %b% times to get out of the well
pause
```
Question 25:
```
@echo off
set/a a=(200-79*2)/(4-2)
set/a b=79-a
echo There are %b% chickens and %a% dogs
pause
```
Floor 86 Posted 2006-11-25 07:13 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Question 26:
@echo off
set/a a=(100*4-100*1)/(4*4-1)
set/a b=100-a
echo There are %b% little monks, and %a% big monks
pause
Floor 87 Posted 2006-11-25 11:58 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
Appreciate the prime number search program by the moderator;

It seems that the moderator's solution for 24, 25, 26 is by solving equations oh
Floor 88 Posted 2006-11-25 12:10 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
Find numbers within 1-43 such that the product of any two numbers is equal (e.g., 2*3=6 and 1*6=6)

Paste a piece of my immature code:

@echo off
setlocal enabledelayedexpansion

for /l %%a in (2 1 49) do (
for /l %%b in (%%a 1 49) do (
title %%a %%b
set /a mult=%%a*%%b
call :test !mult! %%a %%b
set !mult!=%%a × %%b
)
)
pause>nul

:test
if defined %1 (
echo !%1!=!mult!
echo %2 × %3 =!mult!
echo.)
Floor 89 Posted 2006-11-25 21:48 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Originally posted by youxi01 at 2006-11-24 22:58:
Appreciate the prime number search program of the moderator "Can't Help Loving You";

It seems that the moderator's solutions for 24, 25, 26 are in the form of solving equations哦

Wasn't solving chicken and rabbit problems in primary school done this way? Do we still need to solve equations?
Floor 90 Posted 2006-11-25 21:59 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
There are quite a few numbers missing in the code on floor 88. For example:
2*27=54
3*18=54
6*9=54
1*54=54
But your code only outputs:
2*27=54
3*18=54
‹ Prev 1 4 5 6 7 8 10 Next ›
Forum Jump: