XSLT存档  

不及格的程序员-八神

 查看分类:  ASP.NET XML/XSLT JavaScripT   我的MSN空间Blog
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var repeatLength = 10;
var arr = new Array(repeatLength+1);
document.writeln("|"+(arr).join("a").split("")+"|"); 
//output |a,a,a,a,a,a,a,a,a,a|
  Array(6000).fill("0\r\n").toString(),
  Array(6000).fill("-1\r\n").toString()

//--> </SCRIPT> </BODY> </HTML>

C#

public static string RepeatString(string str, int repeatCount)
        {
            return string.Join("",Enumerable.Repeat<string>(str, repeatCount));
            //return new string(str[0], 10);
        }

Java

String strResult =  TextUtils.join("#", arrayValue);

 

字符补齐

public static string PadRight(string str, int totalWidth, char paddingChar)
        {
            return str.PadRight(totalWidth, paddingChar);
        }

        public static string LeftRight(string str, int totalWidth, char paddingChar)
        {
            return str.PadLeft(totalWidth, paddingChar);
        }
https://ideone.com/YjoyN4
Success #stdin #stdout 0.02s 22232KB //8
000001.0
Success #stdin #stdout 0.03s 22128KB //8
1.000000
Success #stdin #stdout 0.02s 16024KB  //4
1.00

 

posted on 2023-06-08 09:40  不及格的程序员-八神  阅读(2)  评论(0编辑  收藏  举报