02字串的練習(03)

2021-10-01 06:22:37 字數 1381 閱讀 8826

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace 字串練習

//第二種方法:將字串轉換為字元陣列,再將字元陣列轉換為字串

//string str = "abcdefg";

//char chs = str.tochararray();

//for(int i=0;i//

//str = new string(chs);

//將字串「hello c sharp"->"sharp c hello"

//string str = "hello c sharp";

//char cha = ;

//string strnew = str.split(cha, stringsplitoptions.removeemptyentries);

//for(int i=0;i//

//將字元陣列迴圈輸出

//for(int i=0;i//

//將字元陣列轉換成字串輸出

//str= string.join(" ", strnew);

//從email中提取使用者名稱和網域名稱:[email protected]

//string str = "[email protected]";

//int index = str.indexof('@');

//string username = str.substring(0, index);

//string ****** = str.substring(index + 1);

//找所有e的位置

//string str = "abdebbebhebbhejje";

//int index = str.indexof('e');

"第1次出現e的位置是", index);

//int count = 1;

//while(index!=-1)

//// console.writeline("第次出現e的位置", count, index);

//}//第二種方法

//for(int i=0;i//

//}//string str =

"老牛很**";if

(str.

contains

("**"))

console.

writeline

(str)

; console.

readkey()

;}}}

03 字串 基礎

1.string s new string abc 此時記憶體有兩個物件 stringpool裡 abc 堆空間 new string abc string s1 abc 因stringpool裡已經有 abc 物件,所以不會再產生,此時記憶體有兩個物件 string s2 new string a...

(59)字串練習

一 模擬trim方法去除兩端的空格 bh public static void simulatetrim if start end 若為空,則start先執行,等於end end後執行,end 1,所以start end為空串 sop 這是個只含空格的字串 else sop 哈哈 s.substri...

字串 03 字串的氣泡排序 20

時間限制 400 ms 記憶體限制 32000 kb 長度限制 8000 b 判題程式 standard 作者 陳越 浙江大學 我們已經知道了將n個整數按從小到大排序的氣泡排序法。本題要求將此方法用於字串序列,並對任意給定的k 輸入格式 輸入在第1行中給出n和k 1 k輸出格式 輸出氣泡排序法掃瞄完...