湖南某高校一根小稻草 2019-05-30 10:58 采纳率: 100%
浏览 999
已采纳

C语言——统计文件中出现最多的前5个字母

统计附件文件"news.txt"中出现的英文字母的次数,并按次数从高到低的排序打印出现次数最多的5个字母。
统一转化为小写字母进行统计。
(提交包括源代码和可执行文件)

文件news.txt是

The dominant sequence transduction models are based on complex recurrent

or convolutional neural networks in an encoder

decoder configuration.
The best performing models also connect the encoder and decoder through
an attention mechanism. We propose a new
simple network architecture,
the Transformer, based solely on attention mechanisms, dispensing with
recurrence and convolutions entirely. Experiments on two machine
translation tasks show these models to be superior in quality while
being more parallelizab
le and requiring significantly less time to train.

Our model achieves 28.4 BLEU on the WMT 2014 English

to

German
translation task, improving over the existing best results, including

ensembles by over 2 BLEU. On the WMT 2014 English

to

French translation

task, our model establishes a new single

model state

of

the

art BLEU
score of 41.8 after training for 3.5 days on eight GPUs, a small fraction
of the training costs of the best models from the literature. We show
that the Transformer generalizes well to ot
her tasks by applying it
successfully to English constituency parsing both with large and limited
training data.

  • 写回答

3条回答 默认 最新

  • threenewbee 2019-05-30 21:14
    关注

    点击我回答左上角的采纳,采纳本回答和 https://ask.csdn.net/questions/763805 后,可以继续回答你其它问题。

    图片说明

    // Q763806.cpp : This file contains the 'main' function. Program execution begins and ends there.
    //
    
    #define _CRT_SECURE_NO_WARNINGS
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    int arr[26];
    int order[26];
    
    int cmp(const void* a, const void* b)
    {
        return arr[*((int*)b)] - arr[*((int*)a)];
    }
    
    void stat(char* line)
    {
        while (*line != '\0')
        {
            if (*line >= 'A' && *line <= 'Z')
                arr[*line - 'A']++;
            if (*line >= 'a' && *line <= 'z')
                arr[*line - 'a']++;
            line++;
        }
    }
    
    int main()
    {
        char buf[1000];
        FILE* fp;
        memset(arr, 0, sizeof(int) * 26);
        for (int i = 0; i < 26; i++) order[i] = i;
        if ((fp = fopen("..\\news.txt", "r")) != NULL)
        {
            while (fgets(buf, 1000, fp) != NULL)
                stat(buf);
        }
        qsort(order, 26, sizeof(int), cmp);
        for (int i = 0; i < 5; i++)
            printf("top %d: %c %d次\n", i + 1, order[i] + 'a', arr[order[i]]);
        return 0;
    }
    

    top 1: e 116次
    top 2: t 88次
    top 3: n 84次
    top 4: o 73次
    top 5: s 67次

    完整代码和可执行文件在你采纳并留下email 后发给你

    其他人如果也需要,下载:https://download.csdn.net/download/caozhy/11217493

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失