Keep it simple, Stupid !!!
블로그 메뉴
홈
태그
미디어로그
위치로그
방명록
블로그 아이디
스펜서.
검색결과 리스트
글
[Programming Challenge #2] 지뢰찾기
Source Code
2008. 12. 15. 17:40
설정
,
트랙백
댓글
코드가 더럽다...
#include
using namespace std; int direction[8][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, -1}, {1, 1}, {-1, 1}, {1, -1} }; int main() { int x, y; char c; int* miner; int cnt = 1; while(cin >> x >> y) { if(x == y && x == 0) break; miner = new int[x * y]; for(int i=0; i { for(int j=0; j { cin >> c; if(c == '*') { miner[j + i*y] = -1; } else { miner[j + i*y] = 0; } } } for(int i=0; i { for(int j=0; j { if(miner[j + i*y] == -1) { for(int k=0; k<8; k++) { if(i + direction[k][0] >= 0 && i + direction[k][0] < x && j + direction[k][1] >= 0 && j + direction[k][1] < y && miner[j + direction[k][1] + (i + direction[k][0])*y] != -1) { miner[j + direction[k][1] + (i + direction[k][0])*y]++; } } } } } if(cnt != 1) cout << endl; cout << "Field #" << cnt << ":" << endl; for(int i=0; i { for(int j=0; j { if(miner[j + i*y] == -1) cout << '*'; else cout << miner[j + i*y]; } cout << endl; } cnt++; } }
공유하기
게시글 관리
구독하기
Keep it simple, Stupid !!!
posted by
스펜서.
CATEGORY
분류 전체보기
(48)
나는 ?!
(1)
끄적끄적
(16)
Health - Everything
(7)
Grphics
(8)
User Experience
(6)
Linux
(1)
Database
(1)
Web
(6)
Source Code
(5)
Knowhow
(1)
TAG
Ubiquity
다이어트일기
PhysX
PInvokeStackImbalance
DllImportAttribute
FTIR
반사지
Javasript
물리엔진
텍스쳐매핑
최소제곱법
최소자승법
OpenGL
Tab Controls
모질라
텍스쳐좌표
일기
dll
nvidia
Wii
XHTML/CSS
Tabletop
다이어트
남자와 여자
mysql 백업
개발
표준
jquery
IRLED
추세선
RECENT POSTS
RECENT COMMENT
NOTICE
블로그 이사 완료
MY LINK
Rising 炫 - 이글루스.
NUI Group.
Melody of My heart...
nVidia Developer.
Rising 炫.
ARCHIVE
calendar
«
2024.5
»
일
월
화
수
목
금
토
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
검색
COUNTER
Total :
|
Today :
tistory
티스토리툴바
RECENT COMMENT