#include <stdio.h>
void printDup(char *str)
{
int count[256] = {0};
int i = 0;
while (*str != '\0') {
count[*str++]++;
}
for (i = 0; i < 256; i++) {
if (count[i] > 0) {
printf("%c %d\n", i
, count
[i
]); }
}
}
int main()
{
char *str = "Foo Bar";
printDup(str);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIHByaW50RHVwKGNoYXIgKnN0cikKewogICAgaW50IGNvdW50WzI1Nl0gPSB7MH07CiAgICBpbnQgaSA9IDA7CgogICAgd2hpbGUgKCpzdHIgIT0gJ1wwJykgewogICAgICAgIGNvdW50WypzdHIrK10rKzsKICAgIH0KCiAgICBmb3IgKGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICBpZiAoY291bnRbaV0gPiAwKSB7CiAgICAgICAgICAgIHByaW50ZigiJWMgJWRcbiIsIGksIGNvdW50W2ldKTsKICAgICAgICB9CiAgICB9Cn0KCmludCBtYWluKCkKewogICAgY2hhciAqc3RyID0gIkZvbyBCYXIiOwoKICAgIHByaW50RHVwKHN0cik7CgogICAgcmV0dXJuIDA7Cn0K