掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
char s[10][10]をstd::sortでソート (ID:70366)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
うわ、めんどくせー... ↓コレなら楽勝なんですけどねー #include <algorithm> #include <cstdio> #include <cstring> using namespace std; bool cmp_strcmp(char *a, char *b) { return strcmp(a, b) < 0; } int main() { char* tab[10]; int n = 0; tab[n++] = strdup("ab"); tab[n++] = strdup("hello"); tab[n++] = strdup("abd"); sort(tab, tab+n, &cmp_strcmp); // 出力 for (int i = 0; i < n; i++) { puts(tab[i]); free(tab[i]); } }
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.