输入n(n<=35) 请编出以下图形 : n=3时: n=4 n=13 1 1 1 222 222 222 3 333 33333 4 4444444 555555555 66666666666 7777777777777 88888888888 999999999 aaaaaaaa bbbbb ccc d
写个函数把数值转化为货币格式(如:133333.2转133,333,20) 把一般数字转为带千分位分割副并且保留2位小数(多余的小数四舍五入) <script language="javascript"> var oNum = "133388733888.25"; alert(getMoneyFormat(oNum));
function getMoneyFormat(str) { var ls = ""; if(//./.test(str) == false) { str = str + "."; } var oNum = str.replace(/([/d]+)/.(/d*)/,function(a,b,c) { while(/[/d]{3}$/.test(b)) { b = b.replace(/([/d]{3})$/,function(d,e){ls = e+","+ls;return ""}); } ls = ls.replace(//,$/,""); if(b!="") { ls = b+","+ls; } var rs = ""; if(c.length == 1) rs = c+"0"; else if(c.length == 0) rs = "00"; else rs = c; return ls+"."+rs; }); return oNum; } </script>