高精度的题 高手请进

chenxi1987 2003-09-29 10:01:44
Numerically Speaking
A developer of crossword puzzles (and other similar word games) has decided to develop a mapping between every possible word with from one to twenty characters and unique integers. The mapping is very simple, with the ordering being done first by the length of the word, and then alphabetically. Part of the list is shown below.
a 1
b 2
...
z 26
aa 27
ab 28
...
snowfall 157,118,051,752
...
Your job in this problem is to develop a program which can translate, bidirectionally, between the unique word numbers and the corresponding words.
Input prob_6.in
Input to the program is a list of words and numbers, one per line starting in column one, followed by a line containing a single asterisk in column one. A number will consist only of decimal digits (0 through 9) followed immediately by the end of line (that is, there will be no commas in input numbers). A word will consist of between one and twenty lowercase alphabetic characters (a through z).
Output prob_6.out
The output is to contain a single line for each word or number in the input data. This line is to contain the word starting in column one, followed by an appropriate number of blanks, and the corresponding word number starting in column 23. Commas must separate Word numbers that have more than three digits at thousands, millions, and so forth.
Sample Input
29697684282993
transcendental
28011622636823854456520
computationally
*
Expected Output
elementary 29,697,684,282,993
transcendental 51,346,529,199,396,181,750
prestidigitation 28,011,622,636,823,854,456,520
computationally 232,049,592,627,851,629,097
用C或C++
谢谢大家!!

...全文
72 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
mmmcd 2003-09-30
  • 打赏
  • 举报
回复
一个简单的十进制与二十六进制数的互化程序

我的实现方法是:
x 进制数: a0a1a2...an 变 y 进制,
for(i=0;i<=n;i++)
sum=sum*x+ai
其中sum的每一位逢y进一。
frankzch 2003-09-30
  • 打赏
  • 举报
回复
这里不欢迎问源代码的
因为别人没有义务给你打工
虽然我们有很高的热情帮你解决问题

33,006

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧