java完成文字处理屏蔽的功能

主要功能是:

1.输入要屏蔽的词的个数

2.依次输入要屏蔽的词

3.输入要进行屏蔽的语句的个数

4.依次输入要进行屏蔽的语句

5.被屏蔽的词用*号代替

6.对于将要处理文字屏蔽的语句先处理最长的语句,最后处理最短的语句

效果图如下:

java完成文字处理屏蔽的功能_第1张图片

 

代码如下:

package perfect;

/*Sample code to read in test cases:*/
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		BufferedReader br;
		try {
			br = new  BufferedReader(new InputStreamReader(System.in,"gbk"));
			String stopnum = br.readLine();
			int stopNum = Integer.parseInt(stopnum);
			String[] stopStr = new String[stopNum];
			for(int i=0; istopStr[max].length()) {
						max = j;
					}
				}
				if(max != i) {
					String temp = stopStr[i];
					stopStr[i] = stopStr[max];
					stopStr[max] = temp;
				}
			}
			
			String testnum = br.readLine();
			int testNum = Integer.parseInt(testnum);
			String[] testStr = new String[testNum];
			for(int i=0; itestStr[max].length()) {
						max = j;
					}
				}
				if(max != i) {
					String temp = testStr[i];
					testStr[i] = testStr[max];
					testStr[max] = temp;
				}
			}
			
			for(int i=0; i='a'&&ch <='z')||(ch>='A'&&ch <='Z') || (ch>='0'&& ch <='9')) {
						       en++;
							}
						}
						cn = stopStr[j].length() - en;
						tn = cn*2 + en;
						String rep = "";
						for(int m=0; m


 

你可能感兴趣的:(java完成文字处理屏蔽的功能)