C/C++の宿題を片付け ..
[
2ch
|
▼Menu
]
■コピペモード
□
スレを通常表示
□
オプションモード
□このスレッドのURL
■項目テキスト
417:デフォルトの名無しさん 07/09/27 07:02:54 >>396 眠いのに朝からやってやったお(^ω^) ループ文なしでやってみたお。 http://kansai2channeler.hp.infoseek.co.jp/cgi-bin/joyful/img/4980.c 418:デフォルトの名無しさん 07/09/27 07:11:59 - '0' とか意味無かったお・・・。冗長すぎワロタ欝出し脳 419:デフォルトの名無しさん 07/09/27 11:01:25 >>365 420:デフォルトの名無しさん 07/09/27 11:09:09 >>396 1/2 char *createcs(struct node *list) { char *cs = 0; int i = 0; struct node *p; for (i = 0, p = list->next; p; i++, p = p->next) continue; cs = (char *)malloc(sizeof(char) * (i + 1)); for (i = 0, p = list->next; p; i++, p = p->next) cs[i] = p->element; cs[i] = '\0'; return cs; } 421:デフォルトの名無しさん 07/09/27 11:09:41 >>396 2/2 struct node *mirror_image(struct node *list) { char *cs = createcs(list); struct node *mirror = 0; int i, j, n, maxn_index = -1; for (i = 0; i < strlen(cs); i++) { if (!isdigit(cs[i])) continue; n = cs[i] - '0'; if (i < n || (strlen(cs) - 1 - i) < n) continue; // 無理 if (n < cs[maxn_index] - '0') continue; // 無駄 for (j = 0; j < n; j++) { // n個チェック if (cs[i - (j + 1)] != cs[i + (j + 1)]) break; } if (n == j && cs[maxn_index] - '0' < n) maxn_index = i; } cs[maxn_index + (cs[maxn_index] - '0') + 1] = '\0'; if (0 < maxn_index) { mirror = initclist(&cs[maxn_index - (cs[maxn_index] - '0')]); } else { mirror = (struct node *)calloc(1, sizeof(struct node)); } free(cs); return mirror; }
次ページ
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
レスジャンプ
mixiチェック!
Twitterに投稿
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch
5291日前に更新/230 KB
担当:undef