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

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 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据