Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('d',"\t");
- define('n',"\n");
- $f_=file('step10.in',FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
- $ff_=array(); foreach($f_ as $i=>$f){if (strpos($f,'¤')>1) continue;$ff_[]=$f;} $f_=$ff_;unset($ff_);
- foreach($f_ as $i=>$f){
- if (empty($f)) continue;
- if ($i==0) continue;
- if (($f[0]=='#')&&($i>1)) continue;
- $f=str_replace(',','.',$f);
- $f=str_replace(':',d ,$f);
- $x=explode(d,$f);
- if (trim($x[3])=='') continue;
- if ($i==1) {$x[0]=99;$x[1]=99; continue;}
- // print_r($x);die;
- // [0] => 1
- // [1] => 0
- // [2] => 2.48
- // [3] => 3.03
- // [4] => 2.69
- if (!is_numeric($x[0])) die ($i.". sor: Nem szám van az első mezőben.".n.$f.n);
- if (!is_numeric($x[1])) die ($i.". sor: Nem szám van a második mezőben.".n.$f.n);
- if (!is_numeric($x[2])) die ($i.". sor: Nem szám van a harmadik mezőben.".n.$f.n);
- if (!is_numeric($x[3])) die ($i.". sor: Nem szám van a negyedik mezőben.".n.$f.n);
- if (!is_numeric($x[4])) die ($i.". sor: Nem szám van az ötödik mezőben.".n.$f.n);
- }
- function fract($a){return substr(str_pad($a,17,'0'),0,8);}
- $types=$sor0=$sor=array();
- foreach($f_ as $i=>$f){
- if (empty($f)) continue;
- if ($i==0) continue;
- if (($f[0]=='#')&&($i>1)) continue;
- $f=str_replace(',','.',$f);
- $f=str_replace(':',d ,$f);
- $x=explode(d,$f);
- if (trim($x[3])=='') continue;
- if ($i==1) {$csapatok=$x[0];$x[0]=99;$x[1]=99;}
- $min=min($x[2],$x[3],$x[4]); $max=max($x[2],$x[3],$x[4]); $med=$x[2]+$x[3]+$x[4]-$min-$max;
- $max_med=$max-$med; $max_min=$max-$min;
- //$sorrend=array();$sorrendt=array($x[2],$x[3],$x[4]);asort($sorrendt);foreach($sorrendt as $j=>$tmp){$sorrend[]=$j;}
- //$gyozo=''; if ($x[0]!=99) {if ($x[0]>$x[1]) $gyozo=$sorrend[0]; elseif ($x[0]<$x[1]) $gyozo=$sorrend[2]; else $gyozo=$sorrend[1];}
- if ($x[0]> $x[1]) $gyozo=$x[2];
- elseif ($x[0]==$x[1]) $gyozo=$x[3];
- elseif ($x[0]< $x[1]) $gyozo=$x[4]; else $gyozo=0;
- if ($x[0]==99) $inv=""; else $inv="\e[7m";
- $typ=
- ((($x[2]<$x[3]) && ($x[3]<$x[4]))?"ABC":
- ((($x[2]<$x[3]) && ($x[3]==$x[4]))?"xyy":
- ((($x[2]<$x[3]) && ($x[3]>$x[4]))?($x[2]<$x[4]?"ACB":($x[2]>$x[4]?"BCA":"yxy")):
- ((($x[2]==$x[3])&& ($x[3]<$x[4]))?"xxy":
- ((($x[2]==$x[3])&& ($x[3]==$x[4]))?"zzz" :
- ((($x[2]==$x[3])&& ($x[3]>$x[4]))?"yyx":
- ((($x[2]>$x[3]) && ($x[3]<$x[4]))?($x[2]<$x[4]?"BAC":HA($x[2]>$x[4]?"CAB":"xyx")):
- ((($x[2]>$x[3]) && ($x[3]==$x[4]))?"yxx":
- ((($x[2]>$x[3]) && ($x[3]>$x[4]))?"CBA":"NemLehet"
- )))))))));
- $types[]=$typ;
- $sor0[$i]=array($i,$x[0],$x[1],$x[2],$x[3],$x[4],$typ,$min,$med,$max,$max_med/$max_min);
- $sor[$i] =array($typ,fract($max_med/$max_min),$x[0],$x[1],
- ($x[0]> $x[1]?$inv:"").$x[2].($x[0]> $x[1]?"\e[27m":""),
- (($x[0]==$x[1])&& ($x[0]!=99)?$inv:"").$x[3].($x[0]==$x[1]?"\e[27m":""),
- ($x[0]< $x[1]?$inv:"").$x[4].($x[0]< $x[1]?"\e[27m":""),'',
- ($gyozo==$min?$inv:"").$min.($gyozo==$min?"\e[27m":""),
- (($gyozo!=$min)&&($gyozo!=$max)?$inv:"").$med.(($gyozo!=$min)&&($gyozo!=$max)?"\e[27m":""),
- ($gyozo==$max?$inv:"").$max.($gyozo==$max?"\e[27m":""),
- '',$i,);
- //print implode(d,$sor0[$i]).n;
- // [0] => 0 $i obsolete
- // [1] => 3
- // [2] => 1
- // [3] => 1.91
- // [4] => 3.21
- // [5] => 3.78
- // [6] => ABC
- // [7] => 1.91 min
- // [8] => 3.21 med
- // [9] => 3.78 max
- // [10]=> 0.3048128342246 $max_med/$max_min
- }
- $types=array_values(array_unique($types));
- //print_r($types);die;
- //foreach($types as $typ){print $typ.' '.str_repeat("-",89).n;}
- //print_r($sor);die;
- $out=''; system("clear;echo \e[39m");
- //$sor=sort($sor);
- foreach($sor as $so){$out.=implode(d,$so).n;}
- //foreach($sor as $so){print_r($so);}
- $innen=strpos($csapatok,'-'); print "\e[93m".str_repeat(" ",(26-$innen<1?0:26-$innen)).str_replace('#','',$csapatok)."\e[39m".n;
- $outt=explode(n,$out);
- natsort($outt);
- //\e[1m bold - http://misc.flogisoft.com/bash/tip_colors_and_formatting
- $elozo='';$sorszin[]="\e[32m";$sorszin[]="\e[39m" /* ez a default */ ; $sorstatusz=0;
- foreach($outt as $i=>$out){
- if (empty($out)) continue;
- $x=explode(d,$out);if ($x[2]<$x[3]) $jel='<'; elseif ($x[2]>$x[3]) $jel='>'; else $jel='=';array_splice($x,2,2,$x[2].$jel.$x[3]);$out=implode(d,$x);
- $elej=substr($out,0,4);if ($elej!=$elozo) $sorstatusz=1-$sorstatusz;$elozo=$elej;
- $out=str_replace(" 99=99 "," \e[7m? ?\e[27m ", $out);
- print $sorszin[$sorstatusz].$out.n;
- }
- print "\e[39m";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement