123456789101112131415161718192021222324
#include <iostream> #include <cstring> #define NO_OF_CHARS 26 int main() { const char *c = "abcdefghijklmnopqrstuvwxyz"; int char_count[NO_OF_CHARS] = {0}; srand(time(NULL)); // Generate 100 random character noting down their repeat count. for(int i = 0; i < 100; ++i) { int j = rand() % strlen(c); std::cout << std::endl << c[j]; char_count[j]++; } // Print the repeat count of each character. for(int i = 0; i < NO_OF_CHARS; ++i) std::cout << std::endl << c[i] << ": " << char_count[i]; return 0; }