本帖最后由 neorobin 于 2014-10-23 14:15 编辑
回复 12# ads350668398
呃, 我可不会什么高深的东东, 只是存储方面的东东, 以及位运算, 学习这些, 你最好找专门的书籍, 诸如贴吧, 网帖教程类的通常都是粗糙且极片面甚至充斥作者的错误理解于其中的.
下面的代码假设所有的变量名你都是知道是什么意思的~~, 并且是以你给出的一个数字一行的文本文件来处理的- @echo off & setlocal enabledelayedexpansion
-
- set /a "_min = 255, _min_cnt = 1 << 31 ^ -1"
- for /f %%a in (a.txt) do (
-
- set /a "x = %%a"
- set /a "_cnt_!x:~0,2! += 1"
- set /a "_sum += x"
- set /a "_cnt_odd += x & 1"
- set /a "_cnt_even += ~x & 1"
- set /a "_cnt_triple += ^!(x %% 3)"
- set /a "t = _max - x >> 31, _max = t & x | ~t & _max"
- set /a "t = x - _min >> 31, _min = t & x | ~t & _min"
-
- if not defined @%%a (
- for /f "tokens=2 delims=:" %%c in ('find /c "%%a" a.txt') do (
- set /a "x = %%c, # = %%a"
- set /a "t = _max_cnt - x >> 31, _max_cnt = t & x | ~t & _max_cnt, _max_cnt# = t & # | ~t & _max_cnt#"
- set /a "t = x - _min_cnt >> 31, _min_cnt = t & x | ~t & _min_cnt, _min_cnt# = t & # | ~t & _min_cnt#"
- )
- set "@%%a=."
- )
- )
-
- set _
- pause
复制代码
|