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;
}
相关推荐
River41641 分钟前
Javer 学 c++(十三):引用篇
c++·后端
感哥3 小时前
C++ std::set
c++
Fanxt_Ja4 小时前
【LeetCode】算法详解#15 ---环形链表II
数据结构·算法·leetcode·链表
侃侃_天下4 小时前
最终的信号类
开发语言·c++·算法
茉莉玫瑰花茶4 小时前
算法 --- 字符串
算法
博笙困了4 小时前
AcWing学习——差分
c++·算法
NAGNIP4 小时前
认识 Unsloth 框架:大模型高效微调的利器
算法
NAGNIP4 小时前
大模型微调框架之LLaMA Factory
算法
echoarts4 小时前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
Python技术极客4 小时前
一款超好用的 Python 交互式可视化工具,强烈推荐~
算法