不知道你的语言.写段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]
实在不好意思,我没说清楚是什么语言.我还没学JAVA,你写的代码我是看不懂,你能不能用C或C++写一个呢???谢谢了!!!