Copy codeThe Code is as follows: # include <stdio. h>
Void cotTime ();
Main ()
{
CotTime ();
}
Void cotTime ()
{
Int c, I, nwhite, nother, ndigit [10];
Nwhite = nother = 0;
For (I = 0; I <10; I ++)
{
Ndigit [I] = 0;
}
While (c = getchar ())! = EOF)
{
Switch (c)
{
Case '0': case '1': case '2': case '3': case '4 ':
Case '5': case '6': case '7': case '8': case '9 ':
/* A hash method to determine the number of occurrences of a number from the method of observing the value of the array element
It can be transformed into a fast de-duplication algorithm, which does not need to be sorted first and then de-duplicated. It sacrifices the space performance, but improves the time performance */
Ndigit [c-'0'] + = 1;
Break;
Case '': case '/t': case'/N ':
Nwhite ++; break;
Default:
Nother ++;
Break;
}
}
Printf ("digits = ");
For (I = 0; I <10; I ++)
{
Printf ("% d", ndigit [I]);
}
Printf (", white space = % d, other = % d/n", nwhite, nother );
Return 0;
}