Comment detail

LL Golf Hole 7 - バイト数を読みやすくする (Nested Flatten)
一応YiBまで対応(処理系が対応してればだけど.
変換対象のバイト数はスタイルシートパラメタnで与えます。
449bytes, 実質443bytes
1
2
3
4
5
6
7
8
<transform version="2.0" xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:y="y">
<output method="text"/><param name="n"/>
<variable name="u" select="('B','KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB')"/>
<template match="/"><value-of select="y:f($n,1)"/></template>
<function name="y:f"><param name="m"/><param name="i"/>
<sequence select="if($m&lt;1024)then($m,$u[$i])else
y:f(round-half-to-even($m div 1024,2),$i+1)"/>
</function></transform>
#7312と同じ考えでC++で。入力は標準入力。
133bytes。実質132bytes
1
2
3
#include <iostream>
char*p=" \bKiMiGiTiPiEiZiYi";
main(){double n;std::cin>>n;for(;1024<n;p+=2)n/=1024;std::cout<<n<<*p<<p[1]<<"B";}

Index

Feed

Other

Link

Pathtraq

loading...