Fortran Coder

查看: 10198|回复: 2
打印 上一主题 下一主题

[输入输出] 关于读取字符串(可能动态)和排序

[复制链接]

3

帖子

2

主题

0

精华

新人

F 币
18 元
贡献
10 点
跳转到指定楼层
楼主
发表于 2014-3-6 11:40:59 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 abandon 于 2014-3-6 11:48 编辑

Using names.txt (放在附件), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score.
For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938th name in the list. So, COLIN would obtain a score of 938 × 53             = 49714.
What is the total of all the name scores in the file?
就是所有名字按 ABCD 排序,然后得到他在ABCD排序中的位置,然后A是一分,B是两分这样加,然后乘以位置数,求和。
因为不知道里面具体有多少个名字,所以可能用到动态读取。自己是编程 菜鸟,fortran刚开始,希望那位好心的大神可以帮忙读取这个文件,最好是一个字符串数组,每个元素存一个名字。排序的话,要是有大神愿意提供代码更是感激不尽!!

names.txt

45.36 KB, 下载次数: 2

分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-18 07:25

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表