本帖最后由 pcl_test 于 2016-11-3 21:22 编辑
猜的- //&cls&2>nul md "结果"&dir /a-d/b *.txt|cscript -nologo -e:jscript "%~f0"&pause&exit
-
- var fso=new ActiveXObject('Scripting.FileSystemObject');
- while(!WSH.StdIn.AtEndOfStream){
- var line = WSH.StdIn.ReadLine();
- fso.CreateTextFile('结果\\'+line,2).Write(fk(line));
- }
- WSH.echo('Done');
-
- function fk(f){
- var text = fso.OpenTextFile(f, 1).ReadAll(), s='';
- var head = text.match(/^\s*深度.+\n/);
- if(head)s+=head[0];
- var body = text.match(/-?\d[^\r\n]+/g).sort(function(a,b){
- return a.split(/\s+/)[0]-b.split(/\s+/)[0]
- });
- if(body){
- if(body.length>1){
- for(var i=0;i<body.length-1;i++){
- var a=body[i].split(/\s+/)[0]*1;
- var b=body[i+1].split(/\s+/)[0];
- var t=b-a;
- if(t==0){
- s+=body[i]+'\r\n'+a+' -999.25\r\n';
- }else{
- s+=body[i]+'\r\n'+((a+t*(Math.random()*0.9+0.1)).toFixed(2)+' -999.25\r\n');
- }
- }
- }
- s+=body[body.length-1]+'\r\n'+(body.pop().split(/\s+/)[0]*1+(Math.random()*9.9+0.1)).toFixed(2)+' -999.25';
- }
- return s;
- }
复制代码
|