本帖最后由 CrLf 于 2015-8-14 05:58 编辑
回复 20# terse
我更喜欢这样的流程:- @if(0)==(0) echo off & cscript.exe -NoLogo -E:JScript %0 <a.txt>b.txt & pause & exit @end
-
- var arr = WScript.StdIn.ReadALL().match(/\d+-\d+/g);
-
- if(arr){
- var obj = {};
-
- arr = arr.sort().reverse();
-
- for(var i = arr.length; --i ;){
- var a = arr[i];
- obj[a] = a in obj?obj[a]+1:1;
- }
-
- for(var i in obj){
- WScript.Echo(i + '\t' + obj[i] + '次');
- }
- }
复制代码 或者肥猪流的像这样:- @if(0)==(0) echo off & cscript.exe -NoLogo -E:JScript %0 <a.txt>b.txt & pause & exit @end
-
- var obj={};
- WScript.StdIn.ReadALL().replace(
- /\d+-\d+/g,
- function(s){
- s in obj?obj[s]++:obj[s]=1;
- }
- );
-
- var arr=[];
- for(var i in obj) {
- arr.push(i + '\t' + obj[i] + '次');
- };
-
- WScript.Echo(arr.sort().join('\r\n'));
复制代码
|