/* Statistical characters
Problem description
Counts the number of times a specified character appears in a given string.
Input
The test input contains several test cases. Each test case contains two rows. 1st act as a string of no more than 5 Characters and 2nd act as a string of no more than 80 characters. Note that the string contains spaces, which may also be one of the characters to be counted. When '#' is read, the input ends, and the corresponding results are not output.
Output
For each test case, count the number of times each character of the string in the 1st line appears in the string in the 2nd line, and output it in the following format:
C0 N0
C1 N1
C2 N2
...
Among them, CI is the I character in line 1st, and Ni is the number of times that CI appears.
Sample Input
I
This is a test
I ng
This is a long test string
#
Sample output
I 2
I 3
5
N 2
G 2
Note: Among the 2nd test cases, space is also one of the statistical characters.
*/
# Include <stdio. h>
# Include <string. h>
Int main ()
{
Int len1, len2;
Char A [6], B [81];
Int C [6], I, J;
While (gets (a) & strcmp (,"#")! = 0) // It cannot be written as while (gets ()! = "#"). If the write operation times out.
{
Int C [6] = {0 };
Gets (B); // gets (B) does not require getchar () to absorb carriage returns; otherwise, it is wrong.
Len1 = strlen ();
Len2 = strlen (B );
For (I = 0; I <len1; I ++)
{
For (j = 0; j <len2; j ++)
{
If (A [I] = B [J])
C [I] ++;
}
Printf ("% C % d \ n", a [I], C [I]);
}
}
Return 0;
}