以简短形式转换一组有意义的单词

时间:2015-11-18 07:52:42

标签: java

例如:美国它应该打印美国而不是USOA它应该排除类似的词,和,用:

import java.io.*;

class m dabest {
    public static void main(String[] args) throws IOException {
        InputStreamReader cr = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(cr);
        int i, oy, l;
        String st,er;
        char r,n;

        st = in.readLine();
        er = " " + st + " ";
        l = e.length();
        for (i=0; i < l-1; i++) {
            r = er.charAt(i);
            if (r == ' ') {
                for (oy=i; oy < i+1; oy++) {
                    n = er.charAt(oy);
                    System.out.println(n + " ");
                }
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

import java.io.*;

class mdae
{
    public static void main(String[] args)throws IOException
    {
        InputStreamReader cr = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(cr);
        int i, oy,l;
        String s,q,ioo=" ";
        char c,v;
        s=in.readLine();
        s=s.replaceAll("of","");
        q=" "+s+" ";
        l=q.length();
        for(i=0;i<l-1;i++)
        {
            c=q.charAt(i);
            if(c==' ')
            {
                for(oy=i;oy<=i+1;oy++)
                {
                    v=q.charAt(oy);
                    if(v!=' ')
                    {
                        ioo=ioo+v;
                    }
                }
            }
        }
        System.out.print(ioo);
    }
}