求乙個字串陣列的最大值和次大值

2021-09-14 02:35:49 字數 694 閱讀 7569

#include #include #include /*

求乙個字串陣列的最大值和次大值*/

void big(char *arr, int size, char** big1, char** big2);

int main();

char *maxstr = strs[0], *secstr = strs[0]; //最大字串和次大字串的指標

big(strs,6,&maxstr,&secstr);

for (int i = 0; maxstr[i] != '\0'; ++i) //輸出最大字串

printf("%c",maxstr[i]);

printf("\n");

for (int i = 0; secstr[i] != '\0'; ++i) //輸出次大字串

printf("%c", secstr[i]);

printf("\n");

system("pause");

return 0;}

void big(char* arr, int size, char** big1, char** big2)

else

else if (strcmp(*big2, arr[i]) < 0)}}

}

比較字串陣列,需要用到的函式是 strcmp 返回值是 

在乙個字串中尋找另外乙個字串

在乙個字串中尋找另外乙個字串 public class text foundit true break test system.out.println foundit?found it didn t find it 該段程式有點難以理解,主要就是if語句的理解,if searchme.charat ...

php判斷乙個字串包含另乙個字串

a 58252,58253 如果 a 中存在 b,則為 true 否則為 false。b 58253 if strpos a,b false else 查詢字串在陣列中出現的次數 array array 1,hello 1,world hello 11 計算 string在 array 需為陣列 中...

SQL 判斷乙個字串是否在另外乙個字串中

eg str1 admin str2 1234,123admin,xcxx 比較str1是否在str2中 用常用的charindex,返回肯定是有值的,這裡自己動手寫乙個方法 檢查乙個字串是否在另外乙個字串中數,另外乙個字串元素用,隔開 create function dbo checkstrina...