1 条题解
-
0
C++ :
#include <bits/stdc++.h> using namespace std; int n; char g[35][35]; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int main() { cin >> n; memset(g, '#', sizeof(g)); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> g[i][j]; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (g[i][j] == '*') { for (int k = 0; k < 4; k++) { int x = i; int y = j; while (g[x][y] != '#') { if (g[x][y] == '.') g[x][y] = 'o'; x += dx[k]; y += dy[k]; } } } int ans = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (g[i][j] == 'o' || g[i][j] == '*') ans++; cout << ans << "\n"; return 0; }
- 1
信息
- ID
- 1974
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 9
- 标签
- (无)
- 递交数
- 9
- 已通过
- 4
- 上传者