主頁 > 知識庫 > 文本最末列數(shù)值乘一個數(shù)的批處理實現(xiàn)

文本最末列數(shù)值乘一個數(shù)的批處理實現(xiàn)

熱門標簽:用電話機器人取代人工 aa專業(yè)電話外呼系統(tǒng) 無錫極信防封電銷卡價格 浙江語音外呼系統(tǒng)招商 谷歌地圖標注錯位 95專業(yè)外呼線路是怎么回事 外呼獲客系統(tǒng) 沈陽電銷 四川防封電銷卡套餐
a.txt

1##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######

以#和空格作為分隔符,最后一列的數(shù)值乘以7,其他不變。
已知的條件,數(shù)字是隨機的,最末列的數(shù)值是整數(shù),即使乘以7,仍在CMD所能計算范圍內(nèi)。
#與空格與“.”的位置和數(shù)量與每行的列數(shù)都是隨機的。
輸出如下:

1##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######

只是對最末列的數(shù)值進行運算操作,其他不變。
要求通用,高效。

ieutk:
復(fù)制代碼 代碼如下:

@echo offsetlocal enabledelayedexpansion
for /f "usebackq skip=35 delims=" %%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
set "_num%x%=%a%"
set /a _num%num%*=7
set "_str1%x%=!_strn%x%:~0,-%y%!"
goto :eof

1##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:
復(fù)制代碼 代碼如下:

@echo offsetlocal 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
pausegoto :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*=7set 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:
復(fù)制代碼 代碼如下:

@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 '/*處理浮點///
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:

方法一:(用時0.25~0.30秒)
復(fù)制代碼 代碼如下:

@echo offsetlocal enabledelayedexpansion
for /f "delims=" %%i in (LastNumberChange.txt) do set/a n+=1set LastLine=$%%i$
for /f "delims=" %%i in (LastNumberChange.txt) do (
set/a m+=1
if %n% neq !m! call set "all=!all!%%iecho."
)

:start
set FirstNumber=%LastLine:~,1%
set "all1=!all1!%FirstNumber%"
set LastLine=%LastLine:~1%
echo %LastLine%|findstr "[0-9]" >nulgoto :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

方法二:(用時0.02~0.05秒)
復(fù)制代碼 代碼如下:

@echo offsetlocal enabledelayedexpansion
for /f "delims=" %%i in (LastNumberChange.txt) do set/a n+=1set LastLine=$%%i$
for /f "delims=" %%i in (LastNumberChange.txt) do (
set/a m+=1
if %n% neq !m! call set "all=!all!%%iecho."
)
: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:
復(fù)制代碼 代碼如下:

@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>nulgoto :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*=7goto :eof
)
)
goto lp

 

隨風(fēng):
復(fù)制代碼 代碼如下:

@echo offsetlocal EnableDelayedExpansion
for /l %%a in (0 1 9) do set .%%a=%%a
for /f "delims=" %%a in (a.txt) do (
set flag=set num=set sun=set "str=%%a"
call :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!goto loop
set /a num*=7
echo !str!!num!!sun:~1!
goto:eof

標簽:南平 迪慶 連云港 廣安 青島 常德 煙臺 興安盟

巨人網(wǎng)絡(luò)通訊聲明:本文標題《文本最末列數(shù)值乘一個數(shù)的批處理實現(xiàn)》,本文關(guān)鍵詞  文本,最末,列,數(shù)值,乘,一,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《文本最末列數(shù)值乘一個數(shù)的批處理實現(xiàn)》相關(guān)的同類信息!
  • 本頁收集關(guān)于文本最末列數(shù)值乘一個數(shù)的批處理實現(xiàn)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章