練習題合集

2021-08-26 03:01:30 字數 1022 閱讀 3699

public class stringexercises 

//1.編寫程式將 「jdk」 全部變為大寫,並輸出到螢幕,

//擷取子串」dk」 並輸出到螢幕

public static void test1()

//2.編寫程式將string型別字串」test」 變為 「tset」.

public static void test2()

//3.寫乙個方法判斷乙個字串是否對稱

public static void test3() else

}//string s = "113@ ere qqq yyui" 輸出所有

//不包含特殊字元的字串

public static void test4()

}//編寫乙個程式,將下面的一段文字中的各個單詞的字母順序翻轉,

//「to be or not to be.",將變成"ot eb ro ton ot eb."。

public static void test5()

result.replace(result.length() - 1, result.length(), ".");

system.out.println(result.tostring());

//方法2:轉換為乙個字元陣列,然後末尾新增乙個句號

//,開始去掉乙個句號

char chars = s.tochararray();

for (int i = chars.length - 1; i >= 1; i--)

system.out.print(".");

}/**

* 6.string s=」name=zhangsan age=18 classno=090728」;

將上面的字串拆分,結果如下:

zhangsan 180 90728

*/public static void test6()

system.out.println(sb);

}

c語言練習題合集2

有乙個3 4的矩陣,要求程式設計序求出其中值最大的那個元素的值,以及其所在的行號和列號。include intmain max a 0 0 for i 0 i 3 i printf 最大的元素是 d,在 d行,在 d列 max,i,j 輸入一行字元,統計其中有多少個單詞,單詞之間用空格分隔開。inc...

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...

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...