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;
}
相关推荐
Yingye Zhu(HPXXZYY)32 分钟前
ICPC 2023 Nanjing R L 题 Elevator
算法
晚风(●•σ )2 小时前
C++语言程序设计——06 字符串
开发语言·c++
晚云与城3 小时前
今日分享:C++ -- list 容器
开发语言·c++
兰雪簪轩3 小时前
分布式通信平台测试报告
开发语言·网络·c++·网络协议·测试报告
程序员Xu4 小时前
【LeetCode热题100道笔记】二叉树的右视图
笔记·算法·leetcode
笑脸惹桃花4 小时前
50系显卡训练深度学习YOLO等算法报错的解决方法
深度学习·算法·yolo·torch·cuda
阿维的博客日记4 小时前
LeetCode 48 - 旋转图像算法详解(全网最优雅的Java算法
算法·leetcode
GEO_YScsn5 小时前
Rust 的生命周期与借用检查:安全性深度保障的基石
网络·算法
程序员Xu5 小时前
【LeetCode热题100道笔记】二叉搜索树中第 K 小的元素
笔记·算法·leetcode
jingfeng5146 小时前
C++11可变参数模板、emplace系列接口、包装器
开发语言·c++