PTA 乙级 1066 图像过滤

2019-04-15 14:03发布

代码实现:

#include #include int main() { int m, n, a, b, rp_color, **pic; scanf("%d %d %d %d %d", &m, &n, &a, &b, &rp_color); pic = (int**)malloc(sizeof(int*)*m); for (int i = 0; i < m; i++) pic[i] = (int*)malloc(sizeof(int)*n); for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) { scanf("%d", &pic[i][j]); if (pic[i][j] >= a && pic[i][j] <= b) pic[i][j] = rp_color; } for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) if (j == 0) printf("%03d", pic[i][j]); else if (j != n - 1) printf(" %03d", pic[i][j]); else printf(" %03d ", pic[i][j]); return 0; }