Study
2008. 9. 28. 23:59
minigame
#include <iostream> #include <ctime> #include <cstdlib> using namespace std; #define chance 10 int game1(); int main(void) { game1(); return 0; } int game1(void) { srand(static_cast<unsigned int>(time(0))); int number; int input; int count; number = rand()%999; cout << "Enter number (range 0~999)" << endl; for(count = 0; count <= chance; count++) { if (count == chance) { cout << "Game Over :p" << endl; exit(0); } cout << "You have " << chance-count << " chance : "; cin >> input; if (input > number) cout << "number is bigger than key" << endl; else if (input < number) cout << "number is lower than key" << endl; else if (input == number) { cout << "Congratulation! The number is " << number << " !!" << endl; exit(0); } } return 0; }
간단하고 재밌는거 몇개 더 추가해서,
내년에 워게임용 자료로나 써볼까 -_-)
공유하기
게시글 관리
솔직한 목소리
blog
profile
tag cloud
travel log
guest book
by
bslime
전체보기
(52)
목소리
(1)
영화
(0)
음악
(0)
Study
(34)
Security
(12)
Web
(2)
WLAN
(7)
Network
(1)
System
(1)
Wargame
(5)
Web
(0)
Reverse Engineering
(3)
Crypto
(2)
CTF
미로
Maze
티스토리
Algorithm
초대장
padocon
삽질
폐인
잘했어요
«
2025/01
»
일
월
화
수
목
금
토
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
darktoil.
인생여전龍군.
슝이.
MR-J@.
미움.
vvipbeom.
Copyright ⓒ 2010.
bslime
, Skin designed by
Creasmworks.
All rights reserved.
티스토리툴바