编程介的小学生 2017-05-09 11:00 采纳率: 20.5%
浏览 756
已采纳

Etaoin Shrdlu

The relative frequency of characters in natural language texts is very important for cryptography. However, the statistics vary for different languages. Here are the top 9 characters sorted by their relative frequencies for several common languages:
English: ETAOINSHR
German: ENIRSATUD
French: EAISTNRUL
Spanish: EAOSNRILD
Italian: EAIONLRTS
Finnish: AITNESLOK

Just as important as the relative frequencies of single characters are those of pairs of characters, so called digrams. Given several text samples, calculate the digrams with the top relative frequencies.

Input

The input contains several test cases. Each starts with a number n on a separate line, denoting the number of lines of the test case. The input is terminated by n = 0. Otherwise, 1 <= n <= 64, and there follow n lines, each with a maximal length of 80 characters. The concatenation of these n lines, where the end-of-line characters are omitted, gives the text sample you have to examine. The text sample will contain printable ASCII characters only.

Output

For each test case generate 5 lines containing the top 5 digrams together with their absolute and relative frequencies. Output the latter rounded to a precision of 6 decimal places. If two digrams should have the same frequency, sort them in (ASCII) lexicographical order. Output a blank line after each test case.

Sample Input

2
Take a look at this!!
!!siht ta kool a ekaT
5
P=NP
Authors: A. Cookie, N. D. Fortune, L. Shalom
Abstract: We give a PTAS algorithm for MaxSAT and apply the PCP-Theorem [3]
Let F be a set of clauses. The following PTAS algorithm gives an optimal
assignment for F:
0

Sample Output

a 3 0.073171
!! 3 0.073171
a 3 0.073171
t 2 0.048780
oo 2 0.048780

a 8 0.037209
or 7 0.032558
. 5 0.023256
e 5 0.023256
al 4 0.018605

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-05-25 15:56
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog