1、-个不断循环的程序,通过system.in读入句子,进行简单的词法分析后,由system.out送出对话回答
   2、不要求实现复杂的人工智能,只要能输出即可

解决方案 »

  1.   

    import java.io.*; 
    public class Doctor

    public static void main(String [] args) throws IOException 

    Doctor dr=new Doctor(); 
    dr.talk(System.in,System.out);//System 类中in为InputStream,out 为 OutStream类型 

    void talk(InputStream in,OutputStream out) throws IOException 

    BufferedReader rd=new BufferedReader( 
    new InputStreamReader(in)); 
    PrintWriter pw=new PrintWriter( 
    new OutputStreamWriter(out),true); 
    pw.println("Hello,I am a Robot-Doctor,I know many things,what are you want to know?"); 
    while(true) 

    String question=rd.readLine(); 
    reply(pw,question); } } 
    void reply(PrintWriter pw,String question) throws IOException 

    if(0==question.compareTo("I love you,Miss Ma!")) 
    pw.println("I love you,too"); 
    else if(question.compareTo("Who are you?")==0) 
    pw.println("I am Dactor Ma!"); 
    else if(0==question.compareTo("1+1=")) 
    pw.println("haha ,I know,It's 2!"); 
    else pw.println("I am sorry!I don't know what You said! "+question+" what's it meas!!! mm mm..."); } 

      

  2.   

    夷~~我初学JAVA的时候,我的老师(翁恺)也是出了这道题目(精神病医生)类似简单的图灵机,莫非楼主是我的师弟?