Fotolog
Volver a la lista de problemas
What's Cryptanalysis?
10008.c
/* 10008 - What's Cryptanalysis? */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int let[255];
void
process(char * str) {
while (*str) {
if (isalpha(*str)) {
*str = toupper(*str);
let[(int)*str]++;
}
str++;
}
}
void
calc(void) {
while (1) {
int i;
int l,nl=0;
for (i='A'; i<='Z'; i++) {
if (let[i] > nl) {
l = i;
nl = let[i];
}
}
if (!nl) {
break;
}
let[l] = 0;
printf("%c %d\n", l, nl);
}
}
int
main(void) {
int n;
int i;
char buf[10240];
memset(let, 0, sizeof(let));
fgets(buf, 1024, stdin);
sscanf(buf, "%d", &n);
for (i=0; i<n; i++) {
fgets(buf, 10240, stdin);
process(buf);
}
calc();
return 0;
}









