看来此题确是有难度,我只要公布自己的代码了(自己看着都晕得很。。。):- @echo off&setlocal enabledelayedexpansion
- set /p str=输入的两数为:
- set /a num_1=0,num_2=0,num=1,v=0
- for %%a in (%str%) do (
- set /a n+=1
- for /f "tokens=1,2 delims=." %%b in ("%%a") do (
- set "_!n!=%%b"
- if "%%c" equ "" (
- set ".!n!=00"&set /a m+=1
- if !m! equ 2 set "flag=a"
- ) else (
- set "a=%%c00"&set "a=!a:~,2!"
- set ".!n!=!a!"
- )
- )
- )
- for %%a in (+#h -#c) do (
- for /f "tokens=1,2 delims=#" %%b in ("%%a") do (
- if "%_1:~,1%" equ "-" set "k1=-"
- if "%_2:~,1%" equ "-" set "k2=-"
- set /a %%c1=_1%%b_2,%%c2=!k1!1%.1%%%100%%b!k2!1%.2%%%100
- if !%%c1! lss 0 (
- if !%%c2! leq -100 set /a %%c2+=100,%%c1-=1
- ) else (
- if !%%c1! equ 0 (
- if !%%c2! lss 0 set "%%c1=-0"&set "a=!%%c2!"&set "%%c2=!a:-=!"
- ) else (
- if !%%c2! lss 0 set /a %%c2+=100,%%c1-=1
- )
- )
- if !%%c2! geq 100 set /a %%c2-=100,%%c1+=1
- )
- )
- for %%a in (h2 c2) do (
- set "a=!%%a!"&set "a=!a:-=!"&set %%a=!a!
- if !a! lss 10 set "%%a=0!a!"
- )
- echo 其和为:%h1%.%h2%&echo 其差为:%c1%.%c2%&set /a n=0
- if defined flag set ".1="&set ".2="
- for %%a in (1 2) do (
- if "!_%%a!" equ "0" (
- set "_%%a="&set /a .%%a=1!.%%a!%%100
- ) else (
- if "!_%%a!" equ "-0" (
- set "_%%a=-"
- ) else (
- set "a=!_%%a!"&set "a=!a:-=!"
- set /a n+=1&call :lp
- )
- )
- if "!.%%a!" neq "" set "a=!.%%a!"&call :loop&set ".%%a=!a!"
- )
- set /a num1=3-num_1+num_2,m=4-v
- if defined flag set /a m=0
- if %num1% leq 0 set /a num1=2
- for /l %%a in (1,1,%num1%) do set /a num*=10
- set /a s=%_1%%.1%*num/%_2%%.2%,j=%_1%%.1%*%_2%%.2%
- if %j% lss 0 set "j=%j:-=%"&set "jk=-"
- if %s% lss 0 set "s=%s:-=%"&set "sk=-"
- if %m% neq 0 if "!j:~%m%!" equ "" set "j=0000%j%"&set "j=!j:~-%m%!"
- if %s% lss %num% set "s=%num:~1%%s%"&set "s=!s:~-%num1%!"
- if %m% neq 0 set "j=!j:~,-%m%!.!j:~-%m%,2!"
- set "s=!s:~,-%num1%!.!s:~-%num1%,2!
- for %%a in (s j) do (
- set "a=!%%a!"
- if "!a:.=!" equ "!a!" (
- set "%%a=!%%a!.00"
- ) else (
- if "!a:~-2,1!" equ "." set "%%a=!%%a!0"
- )
- if "!a:~,1!" equ "." set "%%a=0!%%a!"
- )
- echo 其积为:%jk%%j%&echo 其商为:%sk%%s%
- pause>nul&goto :eof
- :lp
- set /a num_%n%+=1&set "a=%a:~1%"
- if defined a goto lp
- goto :eof
- :loop
- if "%a:~-1%" equ "0" set "a=%a:~,-1%"&set /a v+=1&goto loop
复制代码
[ 本帖最后由 batman 于 2009-2-15 19:16 编辑 ] |