C/C++の宿題を片付けます 93代目at TECHC/C++の宿題を片付けます 93代目 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト16:デフォルトの名無しさん 07/07/16 02:00:27 >>2 とりあえず関数だけ #include <stdlib.h> #include <string.h> void arraycopy (int n, int *dst, int *src) { memcpy (dst, src, sizeof(int)*n); } void mergesort (int n, int *a) { int *b = calloc (n, sizeof(int)); /* temporal space */ int s = 1; /* segment size */ arraycopy (n, b, a); while (s < n) { int f; /* start of segments pair */ for (f = 0; f < n; f += 2*s) { /* merge two segments b[f : f+s], b[f+s : f+2s] into a[f : f+2s] */ int i, i1, i2; i = i1 = i2 = 0; while (i1 != s || i2 != s) { if (i2 == s || i1 != s && b[f+i1] <= b[f+s+i2]) { a[f+i++] = b[f+i1++]; } else { a[f+i++] = b[f+s+i2++]; } } } arraycopy (n, b, a); /* copy a to b */ s *= 2; } free (b); } 17:デフォルトの名無しさん 07/07/16 02:07:21 >>15 ① これでいいかな? #include<stdio.h> int main(void) { char alpha[26] = {0}; char c; int i; printf(" Input: "); do{ c = getchar(); if( 'a'<=c && c<='z' ){ alpha[c-'a']++; } }while( c!=EOF && c!='\n' ); for(i=0;i<26;i++){ if( alpha[i] ){ printf("%c = %d\n",i+'a',alpha[i]); } } return 0; } 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch