编程语言
首页 > 编程语言> > PAT乙级 1066 图像过滤 (13/15 分) Java 实现

PAT乙级 1066 图像过滤 (13/15 分) Java 实现

作者:互联网

 测试点3 又双叒叕超时。实在是没想到15分的题目也卡时间。

import java.io.*;

public class pat1066 {

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StreamTokenizer st = new StreamTokenizer(br);
		st.nextToken();
		int M = (int)st.nval;
		st.nextToken();
		int N = (int)st.nval;
		st.nextToken();
		int A = (int)st.nval;
		st.nextToken();
		int B = (int)st.nval;
		st.nextToken();
		int G = (int)st.nval;
		for(int i=0;i<M;i++) {
			for(int j=0;j<N;j++) {
				st.nextToken();
				int num = (int)st.nval;
				if(num>=A && num<=B) System.out.printf("%03d", G);
				else System.out.printf("%03d", num);
				if(j==N-1) System.out.println();
				else System.out.print(" ");
			}
		}
	}

}

标签:StreamTokenizer,13,nextToken,PAT,int,st,nval,new,1066
来源: https://blog.csdn.net/A1sakaTaiga/article/details/122072528