-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_03.cpp
More file actions
38 lines (32 loc) · 767 Bytes
/
04_03.cpp
File metadata and controls
38 lines (32 loc) · 767 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
/***********************
* date : 2022-04-27
* topic : 구현
* feedback :
* 1. string으로 입력된 숫자를 int로 변환하려면?
* => '0'을 뺴면 됨
* time : 30 min
************************/
#include<iostream>
#include<vector>
using namespace std;
int main_04_03()
{
string point;
cin >> point;
int xx = point[0] - 'a' + 1;
int yy = point[1] - '0';
// 수평으로 두칸 + 수직으로 한칸
// 수직으로 두칸 + 수평으로 한칸
int xarr[8] = {2, 2, -2, -2, 1, 1, -1, -1};
int yarr[8] = {1, -1, 1, -1, -2, 2, -2, 2};
int cnt = 0;
for(int i=0;i<8;i++){
int dx = xx + xarr[i];
int dy = yy + yarr[i];
if(dx<1||dy<1||dx>8||dy>8) continue;
else
cnt++;
}
cout << cnt;
return 0;
}