| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 87603 | bnu_fanmeijie | 图像模糊处理 | C++ | 解答错误 | 0 MS | 260 KB | 1172 | 2026-04-22 15:09:12 |
#include <iostream> #include <cmath> using namespace std; int main() { int n, m; cin >> n >> m; // n=列数, m=行数 // 原图像 int A[105][105]; // 读取原图像 for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { cin >> A[i][j]; } } // 处理并输出 for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { // 边缘像素保持不变 if (i == 0 || i == m - 1 || j == 0 || j == n - 1) { cout << A[i][j]; } // 中间像素计算模糊值 else { // 计算该像素及其上下左右四个像素的平均值 double sum = A[i][j] + A[i-1][j] + A[i+1][j] + A[i][j-1] + A[i][j+1]; double avg = sum / 5.0; // 四舍五入 int result = (int)(avg + 0.5); cout << result; } // 空格处理 if (j < n - 1) { cout << " "; } } cout << endl; } return 0; }