訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容
int i, k, n=0, s[128], nLen [128]; for (i=0; i<128; i++) nLen[i] = 0; FILE * sample = fopen("C:\\Documents and Settings\\User\\桌面\\sample.txt", "r"); while ((i = fgetc(sample)) != EOF) /*計算各個英文字母出現次數(不分大小寫)*/ { k = (char) i; if ( islower(i) != 0) count[i - 71] += 1; else if ( isupper(i) != 0) count[i - 65] += 1; else k = 0; if (k) s[n++] = k; if (k==' ') { s[n-1] = 0; nLen [strlen (s)]++; n=0; } } for (i=0;i<128;i++) printf ("%d : %d", i, nLen[i]);