The last column of text value multiplied by a number of batches implementation _dos/bat

Source: Internet
Author: User
Tags goto
A.txt

#4072.0## #52.19### #72 # #
2#38705.8# # # 51.73## #70 # #
372## #389.0# #51.80# #19.77# # 72#####
4# #59.71#3715.45# #71 ######

With a # and a space as a separator, the last column is multiplied by 7, and the rest is unchanged.
The known condition, the number is random, the last column of the value is an integer, even times 7, still in the scope of the CMD can be computed.
#与空格与 "." The position and number of rows and the number of columns per row are random.
The output is as follows:

#4072.0## #52.19### #504 # #
2#38705.8# # # 51.73## #490 # #
372## #389.0# #51.80# #19.77# # 504#####
4# #59.71#3715.45# #497 ######

Only the last column of the value of the operation operations, the other unchanged.
Requires universal, efficient.

IEUTK:
Copy code code as follows:

@echo off&setlocal enabledelayedexpansion
for/f "Usebackq skip=35 D Elims= '%%a in ('%~dpnx0 ') do (
Set "Var=%%a"
Set "e="
Set "m=0"
set/a num+=1
Call:is%%a "
)
for/l%%a in (1 1%num%) do echo.! _str1%%a!! _num%%a!! _str2%%a!
Pause
goto:eof
: Is
Set "str=%~1"
If "%var:~-1%" LSS "0" (
Set "e=%var:~-1%!e!"
Set "var=%var:~0,-1%" &set/a m+=1
Goto is
)
Set "_str2%num%=%e%
Set" _strn%num%=!str:~0,-% m%! "
Call:su "!_strn%num%!"
goto:eof
: su
Set "a="
Set "U=%~1"
Set "y=0"
: St
for/l%%a in (0 1 9) do if%u:~ -1% "= ="%%a "Set" a=%u:~-1%!a! " &set/a y+=1
Set "u=%u:~0,-1%"
for/l%%a in (0 1 9) do if "%u:~-1%" = "%%a" goto:st
set/a x+=1 Br>set "_num%x%=%a%"
set/a _num%num%*=7
Set "_str1%x%=!_strn%x%:~0,-%y%!"
Goto:eof

#4072.0## #52.19### #504 # #
2#38705.8# # # 51.73## #490 # #
372## #389.0# #51.80# #19.77# # 504#####
4# #59.71#3715.45# #497 ######
5# #4072.0## #52.19### #72 # #
6#38705.8# # # 51.73## #70 # #
772## #389.0# #51.80# #19.77# # 72#####
8# #59.71#3715.45# #71 ######

 

Terse:
Copy Code code as follows:

@echo off&setlocal enabledelayedexpansion
for/l%%i in (0 1 9) do set%%i=%%i
for/f "delims="%%i in (1.txt) do set "str=%%i" &CALL:LP
Pause&goto:eof
: LP
set/a n+=1
Set var=!str:~-%n%,1!
If defined!var! (Set str2=!var!! Str2!&set LP=LP) Else (
If not defined LP (set str1=!var!! str1!) Else (
set/a Str2*=7&set str=!str:~,-%n%!! Var!! str2!! str1!
>>b.txt Echo!str!
For%%i in (STR1 STR2 n LP) do set%%i=
Goto:eof
))
Goto LP

 

YOUXI01:
Copy Code code as follows:

@echo off 2>nul 3>nul
Setlocal enabledelayedexpansion
for/f "delims="%%a in (list.txt) do (
set/a n=0
Set Var=%%a
Set var=!var:#=!
For%%i in (!var!) do set res=%%i
Rem '/* Handling floating-point///
set/a ok=!res! && (set/a res=!res!*7) | | (Set var=!res:*.=!
for/l%%i in (0 1 9) do set var=!var:%%i=%%i!
For%%i in (!var!) do set/a n+=1
Set res=!res:.=!
set/a res=!res!*7
Call set res=%%res:~0,-! n!%%.%%res:~-!n!%%)
Echo!res!
)
Pause>nul

 

huahua0919:

Method One: (spents 0.25~0.30 seconds)
Copy Code code as follows:

@echo off&setlocal enabledelayedexpansion
for/f "delims="%%i in (LastNumberChange.txt) do set/a N+=1&set
for/f "delims="%%i in (LastNumberChange.txt) do (
set/a m+=1
If%n% neq!m! Call set "All=!all!%%i&echo."
)

: Start
Set firstnumber=%lastline:~,1%
Set "all1=!all1!%firstnumber%"
Set lastline=%lastline:~1%
Echo%lastline%|findstr "[0-9]" >nul&&goto:start
: All1
set/a t+=1
Call Set lastone=%%all1:~-!t!%%
set/a x=lastone*1
If "%lastone%" = = "%x%" goto:all1
set/a lastone=%lastone:~1%*7
set/a t-=1
Set xlm=!all1:~,-%t%!
Set "Sum=%all%%xlm%%lastone%%lastline%"
Echo%sum:$=%
Pause

Method Two: (Spents 0.02~0.05 seconds)
Copy Code code as follows:

@echo off&setlocal enabledelayedexpansion
for/f "delims="%%i in (LastNumberChange.txt) do set/a N+=1&set
for/f "delims="%%i in (LastNumberChange.txt) do (
set/a m+=1
If%n% neq!m! Call set "All=!all!%%i&echo."
)
: LaStone
set/a x+=1
Call Set lastone=%%lastline:~-!x!,1%%
set/a mult=%lastone%*1
If not "%mult%" = = "%lastone%" Goto:lastone
set/a x-=1
Call Set front=%%lastline:~,-%x%%%
Call Set last=%%lastline:~-%x%%%
: Middle
set/a x1+=1
Call Set lastone1=%%front:~-!x1!%%
set/a mult1=%lastone1%*1
If "%mult1%" = = "%lastone1%" Goto:middle
set/a middle=%lastone1:~1%*7
set/a x1-=1
Call Set front=%%front:~,-%x1%%%
Set "sum=%all%%front%%middle%%last%"
Echo%sum:$=%
Pause

 

Batman
Copy Code code as follows:

@echo off
for/f "delims="%%i in (1.txt) do (
Set "str=%%i" &set "Begin=a"
Setlocal enabledelayedexpansion
Call:lp
Echo!str!! A!! Var!! last!
Endlocal
)
Pause>nul&goto:eof
: LP
Set "a=%str:~-1%" &set "str=%str:~,-1%"
If "%a%" Geq "0" (
If "%a%" Leq "9" set "Flag=a" &set "begin="
)
If defined flag (
Set Var=%a%!var!&set "flag="
) Else (
If defined begin (
Set last=%a%!last!
) Else (
set/a var*=7&goto:eof
)
)
Goto LP

 

With the Wind:
Copy Code code as follows:

@echo off&setlocal enabledelayedexpansion
for/l%%a in (0 1 9) do s ET.%%a=%%a
for/f "delims="%%a in (a.txt) do (
set flag=&set num=&set sun=&set "str=%%a"
C All:loop
)
Pause
: Loop
Set "var=!str:~-1!"
if defined.! Var! (Set num=!var!! Num!&set flag=a) Else (set sun=!var!! Sun!&set flag=)
If not defined num set Str=!str:~0,-1!&goto loop
If defined flag set STR=!STR:~0,-1!&A Mp;goto Loop
set/a num*=7
Echo!str!! Num!! sun:~1!
Goto:eof

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.