|
本帖最后由 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刚开始,希望那位好心的大神可以帮忙读取这个文件,最好是一个字符串数组,每个元素存一个名字。排序的话,要是有大神愿意提供代码更是感激不尽!!
|
|