批处理版- @echo off&setlocal enabledelayedexpansion
- (
- for /l %%j in (1,1,16) do (
- set/p str[%%j]=
- set "str[%%j]=!str[%%j]:"=0!"
- set "str[%%j]=!str[%%j]:,=0!"
- )
- )<p042_words.txt
- for %%N in (A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do (set/a "i+=1,#%%N=i")
- for /l %%j in (1,1,16) do (
- set/a "p=%%j*100/16"&echo 正在计算...!p!%%
- for /l %%i in (0,1,1080) do (
- set "Char=!str[%%j]:~%%i,1!"
- if not "!Char!"=="0" (
- set/a "sum+=#!Char!"
- ) else (
- for /l %%k in (1,1,20) do (
- set/a "k=%%k*(%%k+1)/2"
- if !k! equ !sum! (set/a "n+=1")
- )
- set/a "sum=0"
- )
- )
- )
- set/p=共有!n!个三角数单词
复制代码
|