練習題(好難的)

2021-09-18 02:09:51 字數 978 閱讀 9460

1、字串轉化(壓縮)  "aabbccdaa" -> "a2b2c2d1 a2"函式原型:

public static string stringcompress(string str) {}

public class testdemo //拼接

c1 = c2;//個數清零

count = 1;

}//加上最後乙個字元和個數

return result.tostring();

}public static void main(string args)

}

2、統計字串中數字個數

//如: "abc21b416u"===>輸出5函式原型:

public static int isnumeric(string str){}

public class testdemo2 

}return count;

}public static void main(string args)

}

3、題目: *****i am biter逆置為: biteram i函式原型:

public class testdemo4 

public static string reversesentence(string str)

for (int j = 0; j < n; j++)

string str1 = new string(arr1);

str=string.valueof(array1);

system.out.println(str1);

}public static void main(string args)

}

public static void leftrotatestring(string str,int n){}

python的練習題 Python練習題

1 使用while迴圈輸入1 2 3 4 5 6 8 9 10 i 0while i 10 i i 1 if i 7 continue print i 結果 e python python python test.py1 2 求1 100的所有數的和 i 0sum 0 while i 100 i 1...

python書中練習題 python練習題

1 定義乙個空列表,接收從鍵盤輸入的整數,把列表傳給乙個從大到小排序的函式,再輸出排序後的列表的值 listex b 0 a int input 請輸入列表長度 while b a num int input 請輸入字元 b 1 print listex sum 0 for i in range 0...

HNCPC2019 K 雙向鍊錶練習題 好題

倉庫 前言這題做法很多。1.雙端佇列 啟發式合併.2.list 3.無向圖模擬 4.splay.5.treap 題目大意鏈結 方法一 雙端佇列 啟發式合併 題目看起來就是個大模擬.發現關鍵點 拼接完之後會整體反轉.那麼我們自然想到了用雙端佇列,維護乙個映象即可 思路可見this 但是遇到了第乙個問題...