New feature requirements:
1. small file input. Enter the command under Console.
2. Support command line input file name of English works.
Some core code:
Structure definition:
Defines a struct to hold the number of read words and their statistics.
struct addup{ char word[]; int count;} R;
Read text:
Char temp[]; R fin[10000]={"",0Char file[]; Fflush (stdin); Gets (file); Fp=freopen (file,"R", stdin);
Word Matching:
For each word read, compare the number of previously accessed words in the struct, and if they are the same, update the array if they are different.
while (!feof (FP)) {fscanf (FP), "%s" ,TEMP); Q=strlen (temp); N++for (I=0;i<n;++i ") Span style= "color: #0000ff;" >if (strcmp (fin[i].word,temp) ==0) {fin[i].count++< Span style= "color: #000000;" >; N--breakif (I>=n) {strcpy (fin[n- 1].word,temp); Fin[n-1].count++
Punctuation Determination:
The read string is measured in characters and removed.
for (I=0;i<q;i++if (Temp[i]== , ' | | Temp[i]== ' . "| | Temp[i]== ' ? "| | Temp[i]== ' ! "| | Temp[i]== ' ) Temp[i]= ' \0 ;}
Bubble Sort:
For (i=0;i<n;i++) for (j=0;j<n-i;j++if (fin[j].count<fin[j+1].count) {ls [0]=fin[j+1]; fin[j+1]=fin[j]; fin[j]=ls[0
Output Result:
if (m!=1)
printf ("Total%d words\n\n", m);
else printf ("Total 1 word\n\n");
for (i=0;i<n;i++) {printf ("%s: ", Fin[i].word); s=0; for (j=0;j<fin[i].count;++j) s++; printf ("%d times ", s); printf ("\ n");}
Operation Result:
Function 1:
Function 2:
PSP Table
C |
C |
S |
E |
I |
T |
Analysis |
requirements, design |
15:20 |
15:30 |
0 |
10 |
Coding |
Realize |
15:30 |
16:20 |
0 |
50 |
Document |
Program Description, essay |
23:40 |
0:05 |
0 |
25 |
Discuss |
Program improvements |
-- |
-- |
-- |
-- |
psp2.1 |
|
Planning |
12% |
Development |
59% |
Reporting |
29% |
Word Frequency statistics (second week)