PAT(初級)1066画像フィルタ(15分)JAVAソリューション

ここに画像を挿入説明

サンプル入力:

3 5 100 150 0
3 189 254 101 119
150 233 151 99 100
88 123 149 0 255

出力例:

003 189 254 000 000
000 233 151 099 000
088 000 000 000 255



import java.io.BufferedReader;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int m = sc.nextInt();
	int n = sc.nextInt();
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	
	while(m!=0){
		boolean flag = true;
		for(int i=0;i<n;i++){
			int d = sc.nextInt();
			if(d>=a && d<=b){
				System.out.printf("%s%03d",flag==true?"":" ",c);
				
			}
			else System.out.printf("%s%03d",flag==true?"":" ",d);
			if(i==n-1) System.out.printf("\n");
			flag=false;
		}
		m--;
	}

}}

公開された83元の記事 ウォンの賞賛1 ビュー1023

おすすめ

転載: blog.csdn.net/qq_44028719/article/details/103992650