本帖最后由 回家路上 于 2015-8-30 11:37 编辑
学了set,请教了5楼,也没写好。待改进O(∩_∩)O!- @echo off & setlocal enabledelayedexpansion
- for /f "tokens=1-3 delims=. " %%i in ('sort a.txt') do (
- set d=%%j
- if "%%i"=="!flag!" (
- set /a "neg=^!(!d:~1!+!d!),pos=^!neg,int+=%%j,s=^!((int>>31)-(%%j>>31)),n=^!s,dec-=s*(%%k+0),dec+=n*(%%k+0),int+=dec/10,dec=dec%%10"
- ) else (
- if defined flag (
- set /a "dec=(1+2*(dec>>31))*dec"
- echo;!flag!=!int!.!dec!
- )
- set flag=%%i&set int=%%j&set dec=%%k
- )
- )
- set /a "dec=(1+2*(dec>>31))*dec"
- echo;!flag!=!int!.!dec!
- pause & exit /b
复制代码
- set dec=!dec!00000&set dec=!dec:~,5!&set ndec=%%k00000&set ndec=!ndec:~,5!&set int=!int:*0=!&set nint=%%j&set nint=!nint:*0=!
- set /a rst=!nint!!ndec!+!int!!dec!&set int=!rst:~,-5!&set dec=!rst:~-5!
复制代码
|