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;
}
相关推荐
PAK向日葵6 小时前
【算法导论】PDD 0817笔试题题解
算法·面试
地平线开发者8 小时前
ReID/OSNet 算法模型量化转换实践
算法·自动驾驶
快乐的划水a9 小时前
组合模式及优化
c++·设计模式·组合模式
地平线开发者9 小时前
开发者说|EmbodiedGen:为具身智能打造可交互3D世界生成引擎
算法·自动驾驶
星星火柴93610 小时前
关于“双指针法“的总结
数据结构·c++·笔记·学习·算法
艾莉丝努力练剑11 小时前
【洛谷刷题】用C语言和C++做一些入门题,练习洛谷IDE模式:分支机构(一)
c语言·开发语言·数据结构·c++·学习·算法
C++、Java和Python的菜鸟12 小时前
第六章 统计初步
算法·机器学习·概率论
Cx330❀12 小时前
【数据结构初阶】--排序(五):计数排序,排序算法复杂度对比和稳定性分析
c语言·数据结构·经验分享·笔记·算法·排序算法
散11212 小时前
01数据结构-Prim算法
数据结构·算法·图论