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

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条)

报告相同问题?

悬赏问题

  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统
  • ¥15 快手联盟怎么快速的跑出建立模型