1588, 4/80 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   whqkdnf000
   http://hack-ing.ohpy.com
   C·Î ¸¸µç »ç°Ý°ÔÀÓ(ÁÖ¼®´Þ¾Æ³ùÀ½)

http://www.hackerschool.org/HS_Boards/zboard.php?id=Free_Lectures&no=916 [º¹»ç]


#include <stdio.h>
#include <time.h>
#include <conio.h>
#include <stdlib.h>
/*
* < »ç°Ý°ÔÀÓ >
*
* ȣȯ¼º
* ÀÌ ÇÁ·Î±×·¥Àº Borland C++ 5.5 ¿¡¼­ ÄÄÆÄÀÏÇÏ°í ½ÃÇèµÇ¾ú½À´Ï´Ù.
*
* °ÔÀÓ¼³¸í
* »ç°ÝÀåÀº °¢°¢ Çϳª¾¿ÀÇ È­»ìÀ» Æ÷ÇÔÇÏ°í ÀÖ´Â ¾ÆÈ©°³ÀÇ ·¹ÀÎÀ¸·Î ¸¸µé¾îÁ® ÀÖ½À´Ï´Ù.
* ÇÁ·Î±×·¥ÀÌ ½ÃÀÛµÇ¸é ·¹ÀÎÀÇ ¿À¸¥ÂÊ¿¡ ÇÑ°³ÀÇ Å¸°Ù(X)ÀÌ ³ªÅ¸³³´Ï´Ù.
* ´ç½ÅÀÇ °úÁ¦´Â È­»ìµé ÁßÀÇ Çϳª·Î Ÿ°ÙÀ» ¸ÂÃß´Â °Í ÀÔ´Ï´Ù.
* È­»ìÀ» ½î·Á¸é ·¹ÀÎ ¹øÈ£¸¦ ´©¸£¸é µË´Ï´Ù.
* 25°³ÀÇ Å¸°ÙÀÌ ³ªÅ¸³­ ÈÄ¿¡, °ÔÀÓÀº ³¡³ª°í, ÃÖÁ¾Á¡¼ö°¡ Ãâ·ÂµË´Ï´Ù.
*
* ³­À̵µ º¯°æÇϱâ
* ³­À̵µ¸¦ º¯°æÇÏ·Á¸é ShootArrow(int)ÇÔ¼öÀÇ µÎ¹ø° for·çÇÁ¸¦ º¯°æÇؼ­ È­»ìÀÇ ¼Óµµ¸¦ º¯°æÇÏ¸é µË´Ï´Ù.
* È­»ìÀÌ ÃµÃµÈ÷ ³ª°¥¼ö·Ï ¸ÂÃß±â±îÁöÀÇ ½Ã°£À» ¼ÒºñÇϹǷΠ³­À̵µ´Â ³ô¾ÆÁý´Ï´Ù.
* PlayGame(void)ÇÔ¼öÀÇ TIME_LIMIT°ªÀ» 2ÃÊ·Î ¸ÂÃß¾î ³õ¾Ò±â ¶§¹®¿¡
* È­»ìÀÌ ¹ß»çµÇ´Âµ¥ 2ÃÊ°¡ °É¸°´Ù¸é °ÔÀÓÀÌ ¾ÈµÇÁÒ. ¿ª½Ã Á¦Çѽ𣵵 ¸¶À½´ë·Î ¼öÁ¤Çϼ¼¿ä.
*/

#define true 1
#define false 0
typedef int bool;

void ShowScore(int);
int PlayGame(void);
void EraseTarget(int);
void ShootArrow(int);
int ShowTarget(void);
void DrawScreen(void);

int main(void) {
        int score;
        srand((unsigned) time(NULL));
        DrawScreen();
        score = PlayGame();
        ShowScore(score);
        
        return 0;
}

void DrawScreen(void) {
        int x;
        clrscr();
        gotoxy(20, 11);
        printf("°ÔÀÓÀ» ½ÃÀÛÇÏ·Á¸é ¾Æ¹«Å°³ª ´©¸£¼¼¿ä.");
        getch();
        clrscr();
        
        for (x = 1; x <= 10; x++) {      // ·çÇÁ´Â Çѹø¿¡ ÇÑ °³ÀÇ ÇìÀκ®°ú ÇÑ°³ÀÇ È­»ìÀ» ±×¸°´Ù.
                gotoxy(1, x * 2 + 2);
                printf("-----------------------------------");
                if (x < 10) {
                        gotoxy(1, x * 2 + 3);
                        printf("%d%s", x, "  >>-->");
                }
        }
}

void EraseTarget(int target_position) {
        gotoxy(60, target_position * 2 + 3);
        printf(" ");
}

int PlayGame(void) {
        int score = 0;
        int target_position;
        long start_time;
        bool shot_fired;
        int num;          // °ªÀ¸·Î ÀúÀåÇÏ´Â ¼ýÀÚÅ°
        const int TIME_LIMIT = 2;   // ÇÑ Å¸°Ù´ç Á¦Çѽð£ 2ÃÊ
        
        int x;
        for (x = 1; x <= 20; x++) {         // ÀÌ ·çÇÁ´Â 25°³ÀÇ Å¸°ÙÀ» ºÎ¿©ÇÑ´Ù.
                target_position = ShowTarget();
                start_time =  time(NULL);      // ¿©±â¿¡¼­ ½ÃÀ۽ð£ÀÌ ÀúÀåµÈ´Ù.
                shot_fired = false;
                
                // Á¦Çѽð£°ú ³²Àº È­»ì°³¼ö¸¦ ¾Ë·ÁÁÜ
                gotoxy(44, 2);
                printf("%s%d%s", "³²Àº È­»ì: ", 21 - x, " ");
                gotoxy(10, 2);
                printf("%s%d%s", "ÇÑ Å¸°Ù ´ç ½Ã°£Á¦ÇÑ ", TIME_LIMIT, "ÃÊ");
                
                do {            // ¼±¼ö°¡ »ç°ÝÀ» ÇÒ ¶§±îÁö Å° ÀÔ·ÂÀ» ±â´Ù¸°´Ù.
                        num = getch() - '0';
                        if (num >= 1 && num <= 9) {
                                ShootArrow(num);
                                shot_fired = true;
                        }
                } while (!shot_fired);  
                
                // ½Ã°£ ¾È¿¡(2ÃÊ) Ÿ°ÙÀ» ¸ÂÃß¾úÀ» ¶§ ½ÇÇàµÈ´Ù.
                if ((time(NULL) < start_time + TIME_LIMIT) && num == target_position) {  
                        putchar('\a');
                        ++score;
                }
                EraseTarget(target_position);
        }
        return score;
}

void ShootArrow(int a) {   // ÆĶó¹ÌÅÍ a´Â ¹ß»çÇÑ È­»ìÀÇ ¹øÈ£
        int x;
        long delay;
        for (x = 4; x <= 60; x++) {
                gotoxy(x, a * 2 + 3);     // ·çÇÁÀÇ ¸Å ȸ¸¶´Ù È­»ìÀ» 1¹®ÀÚ¾¿ ¿À¸¥ÂÊÀ¸·Î ¿òÁ÷ÀδÙ.
                printf(">>-->");
                for (delay = 0; delay < 3999999; delay++)  // ÀÌ ÄÚµå·Î È­»ìÀÇ ¼ÓµµÁ¶ÀýÀ» ÇÑ´Ù. ½Ã½ºÅÛÀÇ ¼º´É¿¡ µû¶ó ´Ù¸£´Ù.
                        continue;
                gotoxy(x, a * 2 + 3);
                printf("     ");
        }
        gotoxy(4, a * 2 + 3);
        printf(">>-->");
}

void ShowScore(int score) {
        gotoxy(60, 20);
        printf("-----------------");
        gotoxy(60, 21);
        printf("%s%d", " Your score is ", score);
        gotoxy(60, 22);
        printf("-----------------");
}

int ShowTarget(void) {
        int p = rand() % 9 + 1;         // ÀÌ ³­¼ö´Â Ÿ°ÙÀÌ ³ªÅ¸³¯ ·¹ÀιøÈ£ÀÌ´Ù. 1 ~ 9
        gotoxy(60, p * 2 + 3);
        printf("X");
        return p;
}

  Hit : 17005     Date : 2008/01/15 07:29



    
aloe ¿ì¿Í!! ´ë´ÜÇϽôÙ.. ÀÌ°ÅÀúµµ Ç÷¹ÀÌÇغ¸°í½ÍÀºµ¥ ¾î¶±ÇØÇϳª¿ä? 2008/01/15  
whqkdnf000 ÄÄÆÄÀÏÇؼ­ ÇϽôø°¡, ÄÄÆÄÀÏ·¯ ¾øÀ¸¸é ÇØÄð ftz¿¡¼­ ÄÄÆÄÀÏÇؼ­ ¾²½Ã¸é ‰Ï´Ï´Ù^-. 2008/01/16  
k1rha ÄÄÆÄÀÏÈÄ ½ÇÇàÇÏ·Á´Ï ¿¡·¯°¡ 3°³¶ß³×¿ä 2008/01/16  
whqkdnf000 ¾Æ¸¶ Çì´õÆÄÀÏÀÌ ¾ø¾î¼­ ±×·±°Í°°Àºµ¥¿ä. º¼·£µåC¿¡¼­´Â ÄÄÆÄÀÏÀ߉ϴϴÙ., 2008/01/16  
qkreoghks00 À©µµ¿ì¿ë gcc¿¡¼­´Â ¾ÈµÇ³ª¿ä? (¾ÆÁ÷¾ÈÇغÃÀ½) 2008/01/23  
lvson1004 ºñÁê¾ó½ºÆ©µð¿À·Î µ¹·Áº¸´Ï ¾ÈµÇ³×¿ä ¤Ð¤Ð 2008/02/22  
marin5318 Åͺ¸¿¡¼­ ¾ÈµÅ³×¿ä.......¤Ð¤Ð 2008/03/24  
flsnrtm º¼·£µåC·Î ¾î¶»°Ô ÄÄÆÄÀÏÇØ¿ä? 2008/04/18  
Min-Q ÄÄÆÄÀÏ ¿¡·¯³ª¸é gotoxyÇÔ¼ö¸¦ ¸¸µé¾îÁÖ½Ã¸é µÇ¿ä 2008/04/29
Min-Q ÇÔ¼ö º»Ã¼´Â ³×À̹ö¿¡¼­ gotoxy °Ë»öÇÏ½Ã¸é ¸¹ÀÌ ³ª¿Â´ä´Ï´Ù. 2008/04/29
ahdudqh ¾î¸Ó¸Ó ¤» ¯À̽ó׿© 2008/08/22  
lit02 À©µµ¿ìgcc¾ÈµÅ 2009/05/24  
Àܵ¥½º ¤§¤§ 2024/03/06  
1528   [Æß+ÆíÁý] [C¾ð¾î] TEXT¿¡ »öÀ» ÀÔÈ÷ÀÚ!! TEXT COLOR SET !!![7]     U_SoRang
12/15 18883
1527   À¯Ä¡¿ø ¸¸È­ Å©°Ôº¸±â[11]     ¼ÒÀ¯
09/03 18877
1526   OpenVMS Tutorial[4]     x90c
02/23 18716
1525   [Á¤¸®] ÇØÄ¿½ºÄð F.T.Z trainer Á¤¸® 6 ~ 10[2]     ÃÊÄÝ·¿³ªÀÎ
03/01 18702
1524   ³× Æ® ¿ö Å© °­ ÁÂ[17]     ¼ÒÀ¯
10/05 18675
1523   [°£´Ü] WireShark - °£´ÜÇÑ ÆÐŶ¿¡¼­ ÆÄÀÏ ÃßÃâ ¹æ¹ýÀÔ´Ï´Ù.[1]     Ǫ¸¥ÇÏ´Ã
05/08 18306
1522   - ÇØÄ¿ÀÇ ¼öÁØ¹× ±â¹ý[322]     twinz
08/27 18268
1521   ÅÚ³Ý ¿¡¼­ FTP ¸®´ª½º ¸í·É¾îÁ¤¸®[5]     ±«µµjs
08/02 18009
1520   ½Ã½ºÅÛ ¸®¼Ò½º 99%¿¡ µµÀüÇÏÀÚ!![18]     DarkSlayer
09/10 17650
1519   Á¤º¸Åë½Å ÀÎÅÍ³Ý ¿ë¾î..(¸ð¸£½Ã´Â ºÐµé¸¸..+Âü°í..)[19]     H.R.T
12/29 17545
1518   ¸®´ª½º ¸í·É¾î ¸¶½ºÅÍ 3[13]     ¼ÒÀ¯
09/04 17409
1517   ¶ó¿ìÅÍ °£´ÜÇÑ ¸í·É¾î ¹× ±âº»¼³Á¤[2]     Mach
04/29 17400
1516   ¼ÒÄÏ ÇÁ·Î±×·¡¹Ö[5]     ¼ÒÀ¯
09/11 17316
1515   chenkim4ÀÇ Áß±¹ÇØÅ· ±â¹ý 8°¡Áö Æí[1]     chenkim4
08/28 17263
1514   ¸®´ª½º Mysql ¼³Ä¡Çϱâ. centos6.4 - minimal // mysql 5.6.11 ¼Ò½º      nsh009
05/10 17254
1513   webhacking.kr 2¹ø[1]     ÇÁ¶óÀ̵å
09/28 17244
1512   ÃÊÂ¥¸¦ À§ÇÑ ÆÄÀ̽ã[2]     asdzxc301
12/18 17090
1511   ¸®´ª½º ¸í·É¾î ¸¶½ºÅÍ 4[13]     ¼ÒÀ¯
09/05 17057
  C·Î ¸¸µç »ç°Ý°ÔÀÓ(ÁÖ¼®´Þ¾Æ³ùÀ½)[13]     whqkdnf000
01/15 17004
1509   À©µµ¿ìxp°ü¸®ÀÚ ºñ¹Ð¹øÈ£ °£´ÜÈ÷ ÇØÅ·Çϱâ![14]     whqkdnf000
02/26 16981
[1][2][3] 4 [5][6][7][8][9][10]..[80]

Copyright 1999-2024 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org