您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php实现阿拉伯数字和罗马数字相互转换的方法_PHP

2026/1/24 6:16:12发布28次查看
本文实例讲述了php实现阿拉伯数字和罗马数字相互转换的方法。分享给大家供大家参考。具体如下:
3999 || $f 1000, 'd' => 500, 'c' => 100, 'l' => 50, 'x' => 10, 'v' => 5, 'i' => 1 ); // calculate the needed roman figures: foreach($roman as $k => $v) if(($amount[$k] = floor($f / $v)) > 0) $f -= $amount[$k] * $v; // build the string: $return = ''; foreach($amount as $k => $v) { $return .= $v 1000, 'd' => 500, 'c' => 100, 'l' => 50, 'x' => 10, 'v' => 5, 'i' => 1 ); // convert the string to an array of roman values: for($i = 0; $i $current ? $sum += $next - $current + 0 * next($values) : $sum += $current; } // return the value: return $sum;}// echo roman2dec(ix); ?>
希望本文所述对大家的php程序设计有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product