0018 字串中除首尾字元外的其餘字元按降序排列

2021-09-05 01:35:29 字數 551 閱讀 1952

6-2 字串中除首尾字元外的其餘字元按降序排列 (10 分)

請編寫函式fun,對字串中除首、尾字元外的其餘字元按降序排列。例如,原來的字串為ceaedca,排序後輸出為cedceaa。

int fun(char *s,int num);
其中snum都是使用者傳入的引數。函式對字元指標s所指的字串中除首、尾字元外的其餘字元按降序排列。

#include int fun(char *s,int num);

int main()

/* 請在這裡填寫答案 */

ceaedca
cedceaa
注:1.return *s而不是return s

int fun(char *s,int num)

} }return *s;

}

字串中除首尾字元外的其餘字元按降序排列 PTA

6 2 字串中除首尾字元外的其餘字元按降序排列 10 分 請編寫函式fun,對字串中除首 尾字元外的其餘字元按降序排列。例如,原來的字串為ceaedca,排序後輸出為cedceaa。函式介面定義 int fun char s,int num 其中 s 和 num 都是使用者傳入的引數。函式對字元指標...

去掉字串首尾指定的字元

話不多說直接上 去掉字串頭尾指定字元 param source 需要處理的字串 param element 指定字元 return public static string trimfirstandlastchar string source,char element while begininde...

字串1 字串的旋轉

題目描述 給定乙個字串,要求將字串前面的若干個字元移到字串的尾部。例如 將字串 abcdef 的前三個字元 a b c 移到字串的尾部,那麼原字串將變成 defabc 首先想到的是將需要移動的字元乙個乙個移到字串的尾部。實現如下 public class transfet s n 1 t publi...