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

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 Stata链式中介效应代码修改
  • ¥15 latex投稿显示click download
  • ¥15 请问读取环境变量文件失败是什么原因?
  • ¥15 在若依框架下实现人脸识别
  • ¥15 添加组件无法加载页面,某块加载卡住
  • ¥15 网络科学导论,网络控制
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错