-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountTheMines.cpp
More file actions
42 lines (40 loc) · 958 Bytes
/
CountTheMines.cpp
File metadata and controls
42 lines (40 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Count The Mines
// Wrong answer on test 2
// Author @ Abuhena Rony
#include <bits/stdc++.h>
using namespace std;
int main()
{
char mine_arr[40][40];
int n = 4;
int count = 0;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
char temp = 0;
scanf("%c", &temp);
if (temp == '\n' or temp == ' ' or temp == '\t')
j--;
else
mine_arr[i][j] = temp;
}
}
// display mine array for debugging
// printf("\n");
// for (int i = 0; i < n; i++) {
// for (int j = 0; j < n; j++)
// printf("%d %d => %c\n", i, j, mine_arr[i][j]);
// }
// printf("\n");
for (int row = 0; row < n; row++)
{
for (int col = 0; col < n; col++)
{
if (mine_arr[row][col] == 'm')
count++;
}
}
printf("%d\n", count);
return 0;
}