请牛人指点迷津
不知道你的语言.
写段Java的给你.
[CODE]/*
* TempTest.java
*
* Created on 2007年9月05日, 上午09:00
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.test;
import java.util.*;
import java.io.*;
/**
*
* @author Administrator
*/
public class TempTest {
public static void main(String[] args) throws Exception{
TreeMap<String,Integer> tm=new TreeMap<String,Integer>();
Scanner scanner=new Scanner(new File("e:\dj5.txt"));
while(scanner.hasNext()){
String word=scanner.next();
int count=getCount(word,tm)+1;
tm.put(word,new Integer(count));
}
System.out.println(tm.toString());
}
public static int getCount(String word,TreeMap<String,Integer> tm){
if(tm.containsKey(word)){
return tm.get(word).intValue();
}else{
return 0;
}
}
} [/CODE]