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-06-28 05:20
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to find out which numbers in the text add up to a specified value View 3,753 Replies 48
Floor 46 Posted 2007-03-05 06:10 ·  中国 山东 济南 电信
初级用户
Credits 125
Posts 44
Joined 2007-01-24 15:31
19-year member
UID 77555
Gender Female
Status Offline
Originally posted by youxi01 at 2007-3-3 06:48 PM:
The code is as follows, welcome to test and correct.

@echo off
setlocal enabledelayedexpansion
set num=0
for /f %%n in (test.txt) do (
set /a i+=1
set gn!i!=%%n
)
for /l %%i in (1,1,36) do ...


While compressing the recursive array range, it also compresses the possibility of finding the result.
Floor 47 Posted 2007-03-05 06:36 ·  中国 河北 保定 移动
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
It's relatively difficult to implement with high-level languages, let alone batch processing, as the efficiency is too low.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 48 Posted 2007-03-11 07:42 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
So, the actual numbers of digits are in cases like 35, 36, 37, 38, etc.

Sort and then filter combinations where the sum of the units digit and the tens digit is 80 (because the result requires 171780). After filtering, then find the combinations.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 49 Posted 2007-03-16 04:57 ·  中国 山东 济南 电信
初级用户
Credits 125
Posts 44
Joined 2007-01-24 15:31
19-year member
UID 77555
Gender Female
Status Offline
Originally posted by electronixtar at 2007-3-10 06:42 PM:

Sort, then filter combinations where the sum of the units digit and tens digit is 80 (since the result requires 171780). After filtering, then find the combinations.



Before referring to qzwqzw's code, such an idea had already been tried.
The code was only halfway written when it was discovered that when writing the filter for , it was purely a detour.

Because filtering also requires enumerating permutations and combinations..... Hehe....

Why not just give the result directly? If that's the case, what's the use of sorting... Hehe.....
Forum Jump: