1066 图像过滤


solution

cpp 复制代码
#include<iostream>
using namespace std;
const int maxn = 510;
int arr[maxn][maxn];
int main(){
	int n, m, a, b, x;
	scanf("%d%d%d%d%d", &m, &n, &a, &b, &x);
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			scanf("%d", &arr[i][j]);
			if(arr[i][j] >= a && arr[i][j] <= b) arr[i][j] = x;
		}
	} 
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			printf("%03d", arr[i][j]);
			if(j != n - 1) printf(" ");
		}
		if(i != m - 1) printf("\n");
	}
	return 0;
}

or

cpp 复制代码
#include<iostream>
using namespace std;
int main(){
	int n, m, a, b, x, t;
	scanf("%d%d%d%d%d", &m, &n, &a, &b, &x);
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			scanf("%d", &t);
			if(t >= a && t <= b) t = x;
			printf("%03d", t);
			if(j != n - 1) printf(" ");
		}
		if(i != m - 1) printf("\n");
	} 
	return 0;
}
相关推荐
苏克贝塔36 分钟前
Qt 图形视图框架3-事件处理与传播
c++·qt
用户50408278583937 分钟前
1. RAG 权威指南:从本地实现到生产级优化的全面实践
算法
轩情吖42 分钟前
Qt的信号与槽(二)
数据库·c++·qt·信号·connect·信号槽·
胖大和尚44 分钟前
C++项目学习计划
开发语言·c++·学习
Python×CATIA工业智造2 小时前
详细页智能解析算法:洞悉海量页面数据的核心技术
爬虫·算法·pycharm
GiraKoo3 小时前
【GiraKoo】 C++20的新特性
c++
无聊的小坏坏3 小时前
力扣 239 题:滑动窗口最大值的两种高效解法
c++·算法·leetcode
黎明smaly3 小时前
【排序】插入排序
c语言·开发语言·数据结构·c++·算法·排序算法
YuTaoShao3 小时前
【LeetCode 热题 100】206. 反转链表——(解法一)值翻转
算法·leetcode·链表
YuTaoShao3 小时前
【LeetCode 热题 100】142. 环形链表 II——快慢指针
java·算法·leetcode·链表