最近做了一道面试题。好难受啊
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
我写的太差了,没通过,求高人指点。。。。 值得看看,你怎么不把你的程序贴上来呢 看不懂啊 1.定义一个字典,存放常用的单词,并按使用频率排序。
2.每识别出一个单词,计数加1,只到文件处理完毕。
3.处理大文件,要注意空间和时间上的平衡。 LS正解…
字典是好东西… 我写的太次,被打回了,郁闷中 其实要求很简单,就是数指定文件里的关键字个数,按从多到少排序输出。 怎么没人回答,自己顶,我是用链表实现的,不知道对不对
页:
[1]