wang1216 发表于 2011-9-30 09:06:31

最近做了一道面试题。好难受啊

Please write a C program to do the following:

   - Takes as arguments a file name (for example: input.txt)

   - The input file can be potentially very large

   - The program opens and reads the file

   - The program prints out a distribution of most common words, with most common first, and least common last

   - Whitespace between words consists of space, tab, and enter

   - Treat punctuation such as ,.:; the same as other characters

Example:

input.txt contains:

you hello love programming hello you hello hello you hello

$ ./a.out input.txt

hello 5

you 3

love 1

programming 1
我写的太差了,没通过,求高人指点。。。。

jomin 发表于 2011-9-30 11:29:41

值得看看,你怎么不把你的程序贴上来呢

289457095 发表于 2011-9-30 11:44:39

看不懂啊

zml2006 发表于 2011-9-30 11:56:59

1.定义一个字典,存放常用的单词,并按使用频率排序。
2.每识别出一个单词,计数加1,只到文件处理完毕。
3.处理大文件,要注意空间和时间上的平衡。

yaxi1984 发表于 2011-9-30 12:34:46

LS正解…
字典是好东西…

wang1216 发表于 2011-10-7 22:34:12

我写的太次,被打回了,郁闷中

wang1216 发表于 2011-10-7 22:35:52

其实要求很简单,就是数指定文件里的关键字个数,按从多到少排序输出。

wang1216 发表于 2011-10-9 22:13:18

怎么没人回答,自己顶,我是用链表实现的,不知道对不对
页: [1]
查看完整版本: 最近做了一道面试题。好难受啊