Á¤¼ºÈÆ
    Mini Project (¾îµåº¥Ã³ °ÔÀÓ ¸¸µé±â) Ãß°¡ ±¸Çö // ¡Ú¡Ú¡Ú ±â¸»°úÁ¦ °ÔÀÓ±¸Çö ½Ã Âü°í



¸ð¹ü´ä¾ÈÀº ÃÖ¼ÒÇÑÀÇ °Í¸¸ ±¸ÇöµÇ¾î ÀÖÀ½

Ãß°¡·Î ±¸ÇöÇϸé ÁÁÀº µ¿ÀÛ

  • °æ°è¸¦ ¹þ¾î³ª¸é ¸ø ¿òÁ÷À̵µ·Ï ÇÏ´Â °Í
  • ¸ó½ºÅÍ ¹«ÀÛÀ§ ¿òÁ÷ÀÓ 
  • ¸ó½ºÅÍ¿Í ºÎµúÄ¡¸é °ÔÀÓ Á¾·á (Á¡¼ö Ç¥½Ã)
  • ¸ñÇ¥ÁöÁ¡¿¡ µµÂøÇÏ¸é °ÔÀÓ Á¾·á (Á¡¼ö Ç¥½Ã) // Á¡¼ö´Â Çѹø À̵¿½Ã 1Á¡
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
 
#define    DIFFICULTY    0.8    // 0~1 ·Î ³ôÀ»¼ö·Ï ¾î·Á¿ò
 
#define    get_prob()    rand()/(double) RAND_MAX
 
int main(void)
{
    char board[10][10];
    int xpos = 1, ypos = 1;
    int xpos_m1 = 5, ypos_m1 = 5;
    int xpos_m2 = 7, ypos_m2 = 6;
    int xpos_g=9, ypos_g=9;
    int score=0;
    int num = 0;
 
    // º¸µå¸¦ ÃʱâÈ­ÇÑ´Ù. 
    for (int y = 0; y < 10; y++)
        for (int x = 0; x < 10; x++) board[y][x] = '.';
    board[ypos][xpos] = '#';
    board[ypos_g][xpos_g] = 'G';
    board[ypos_m1][xpos_m1] = 'M';
    board[ypos_m2][xpos_m2] = 'M';
 
    srand(time(NULL));
 
    printf("¿ÞÂÊÀ̵¿:a, ¿À¸¥ÂÊ À̵¿:d À§ÂÊ À̵¿:w, ¾Æ·¡ÂÊ À̵¿:s\n");
    // »ç¿ëÀڷκÎÅÍ À§Ä¡¸¦ ¹Þ¾Æ¼­ º¸µå¿¡ Ç¥½ÃÇÑ´Ù. 
    while (1) {
        system("cls");
        printf("¿ÞÂÊÀ̵¿:a, ¿À¸¥ÂÊ À̵¿:d À§ÂÊ À̵¿:w, ¾Æ·¡ÂÊ À̵¿:s (%d)\n",num++);
        for (int y = 0; y < 10; y++) {
            for (int x = 0; x < 10; x++printf("%c", board[y][x]);
            printf("\n");
        }
        if ((ypos == ypos_m1 && xpos == xpos_m1) || (ypos == ypos_m2 && xpos == xpos_m2)) {
            printf("ij¸¯ÅÍ Á×À½ (Á¡¼ö:%d)",score);
            break;
        }
        if (ypos == ypos_g && xpos == xpos_g) {
            printf("°ÔÀÓÁ¾·á (Á¡¼ö:%d)",score);
            break;
        }
        board[ypos][xpos] = '.';
        board[ypos_m1][xpos_m1] = '.';
        board[ypos_m2][xpos_m2] = '.';
 
        int ch = _getch();
        if (ch == 0) ch = _getch();  // Çѹø ÀÔ·ÂÇصµ µÎ¹ø° 0ÀÌ ¶Ç ÀԷµǴ ¹®Á¦ ÇØ°á
        if (ch == 'a') { if (xpos >= 1) xpos--; }
        else if (ch == 's') { if (ypos <= 8) ypos++; }
        else if (ch == 'w') { if (ypos >= 1) ypos--; }
        else if (ch == 'd') { if (xpos <= 8) xpos++; }
 
        if (get_prob() < DIFFICULTY) {    // monster 1 ¹«ÀÛÀ§ À̵¿
            if (get_prob() < 0.5) {
                if (get_prob() < 0.5) {
                    if (xpos_m1 <= 8) xpos_m1++;
                }
                else {
                    if (xpos_m1 >= 1) xpos_m1--;
                }
            }else {
                if (get_prob() < 0.5) {
                    if (ypos_m1 <= 8) ypos_m1++;
                }
                else {
                    if (ypos_m1 >= 1) ypos_m1--;
                }
            }
        }
        if (get_prob() < DIFFICULTY) {    // monster 2 ¹«ÀÛÀ§ À̵¿
            if (get_prob() < 0.5) {
                if (get_prob() < 0.5) {
                    if (xpos_m2 <= 8) xpos_m2++;
                }
                else {
                    if (xpos_m2 >= 1) xpos_m2--;
                }
            } else {
                if (get_prob() < 0.5) {
                    if (ypos_m2 <= 8) ypos_m2++;
                }
                else {
                    if (ypos_m2 >= 1) ypos_m2--;
                }
            }
        }
 
        board[ypos][xpos] = '#';
        board[ypos_m1][xpos_m1] = 'M';
        board[ypos_m2][xpos_m2] = 'M';
        score++;
    }
    return 0;
}
cs

 

Ãß°¡ÀûÀ¸·Î ±¸ÇöÇϸé ÁÁÀº °Í

  • ij¸¯ÅÍ°¡ ¿òÁ÷ÀÌÁö ¾Ê¾Æµµ ¸ó½ºÅÍ´Â ¿òÁ÷À̵µ·Ï ÇÏ´Â °Í
  • ¸ó½ºÅÍ°¡ ¹«ÀÛÀ§ ÀûÀ¸·Î ¿òÁ÷À̸鼭 Ä³¸¯ÅÍ ÂÊÀ¸·Î ¦i¾Æ¿Àµµ·Ï ÇÏ´Â °Í
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <Windows.h>
 
#define    DIFFICULTY    0.4    // 0~1 ·Î ³ôÀ»¼ö·Ï ¾î·Á¿ò
 
#define    get_prob()    rand()/(double) RAND_MAX
 
void CursorView()
{
    CONSOLE_CURSOR_INFO cursorInfo = { 0, };
    cursorInfo.dwSize = 1//Ä¿¼­ ±½±â (1 ~ 100)
    cursorInfo.bVisible = FALSE; //Ä¿¼­ Visible TRUE(º¸ÀÓ) FALSE(¼û±è)
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);
}
 
void move_monster(int xpos, int ypos, int* xpos_m, int* ypos_m)
{
    if (get_prob() < DIFFICULTY) {      // monster 
        if (get_prob() < get_prob()) {  // ¹«ÀÛÀ§ À̵¿
            if (get_prob() < 0.5) {
                if (get_prob() < 0.5) {
                    if (*xpos_m <= 8) (*xpos_m)++;
                }
                else {
                    if (*xpos_m >= 1) (*xpos_m)--;
                }
            }
            else {
                if (get_prob() < 0.5) {
                    if (*ypos_m <= 8) (*ypos_m)++;
                }
                else {
                    if (*ypos_m >= 1) (*ypos_m)--;
                }
            }
        }
        else {   // Ä³¸¯ÅÍ µû¶ó°¨
            *xpos_m = *xpos_m > xpos ? --(*xpos_m) : *xpos_m < xpos ? ++(*xpos_m) : *xpos_m;
            *ypos_m = *ypos_m > ypos ? --(*ypos_m) : *ypos_m < ypos ? ++(*ypos_m) : *ypos_m;
        }
    }
}
 
int main(void)
{
    char board[10][10];
    int xpos = 1, ypos = 1;
    int xpos_m1 = 5, ypos_m1 = 5;
    int xpos_m2 = 7, ypos_m2 = 6;
    int xpos_g = 9, ypos_g = 9;
    int score = 0;
    int num = 0, ch=0;
 
    CursorView();
    // º¸µå¸¦ ÃʱâÈ­ÇÑ´Ù. 
    for (int y = 0; y < 10; y++)
        for (int x = 0; x < 10; x++) board[y][x] = '.';
    board[ypos][xpos] = '#';
    board[ypos_g][xpos_g] = 'G';
    board[ypos_m1][xpos_m1] = 'M';
    board[ypos_m2][xpos_m2] = 'M';
 
    srand(time(NULL));
 
    printf("¿ÞÂÊÀ̵¿:a, ¿À¸¥ÂÊ À̵¿:d À§ÂÊ À̵¿:w, ¾Æ·¡ÂÊ À̵¿:s\n");
    // »ç¿ëÀڷκÎÅÍ À§Ä¡¸¦ ¹Þ¾Æ¼­ º¸µå¿¡ Ç¥½ÃÇÑ´Ù. 
    while (1) {
        system("cls");
        printf("¿ÞÂÊÀ̵¿:a, ¿À¸¥ÂÊ À̵¿:d À§ÂÊ À̵¿:w, ¾Æ·¡ÂÊ À̵¿:s (%d)\n", num++);
        for (int y = 0; y < 10; y++) {
            for (int x = 0; x < 10; x++printf("%c", board[y][x]);
            printf("\n");
        }
        if ((ypos == ypos_m1 && xpos == xpos_m1) || (ypos == ypos_m2 && xpos == xpos_m2)) {
            printf("ij¸¯ÅÍ Á×À½ (Á¡¼ö:%d)", score);
            break;
        }
        if (ypos == ypos_g && xpos == xpos_g) {
            printf("°ÔÀÓÁ¾·á (Á¡¼ö:%d)", score);
            break;
        }
        board[ypos][xpos] = '.';
        board[ypos_m1][xpos_m1] = '.';
        board[ypos_m2][xpos_m2] = '.';
        
        if (_kbhit() == 1) {
            ch = _getch();
            //if (ch == 0) ch = _getch();  // Çѹø ÀÔ·ÂÇصµ µÎ¹ø° 0ÀÌ ¶Ç ÀԷµǴ ¹®Á¦ ÇØ°á
 
            if (ch == 'a') { if (xpos >= 1) xpos--; }
            else if (ch == 's') { if (ypos <= 8) ypos++; }
            else if (ch == 'w') { if (ypos >= 1) ypos--; }
            else if (ch == 'd') { if (xpos <= 8) xpos++; }
        }
 
        move_monster(xpos, ypos, &xpos_m1, &ypos_m1);
        move_monster(xpos, ypos, &xpos_m2, &ypos_m2);
 
        board[ypos][xpos] = '#';
        board[ypos_m1][xpos_m1] = 'M';
        board[ypos_m2][xpos_m2] = 'M';
        board[ypos_g][xpos_g] = 'G';
        score++;
            
        Sleep(200);
    }
    return 0;
}
cs


Ãß°¡ÀûÀ¸·Î ±¸ÇöÇϸé ÁÁÀº °Í

  • ¸ó½ºÅ͸¦ ¿©·¯ °³·Î ¼³Á¤ÇÒ ¼ö ÀÖµµ·Ï ÇÏ´Â °Í
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <Windows.h>
 
#define     DIFFICULTY    0.4    // 0~1 ·Î ³ôÀ»¼ö·Ï ¾î·Á¿ò
#define     NUM_MONSTER     5
 
#define    get_prob()    rand()/(double) RAND_MAX
 
void CursorView()
{
    CONSOLE_CURSOR_INFO cursorInfo = { 0, };
    cursorInfo.dwSize = 1//Ä¿¼­ ±½±â (1 ~ 100)
    cursorInfo.bVisible = FALSE; //Ä¿¼­ Visible TRUE(º¸ÀÓ) FALSE(¼û±è)
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);
}
 
void move_monster(int xpos, int ypos, int* xpos_m, int* ypos_m)
{
    if (get_prob() < DIFFICULTY) {      // monster 
        if (get_prob() < get_prob()) {  // ¹«ÀÛÀ§ À̵¿
            if (get_prob() < 0.5) {
                if (get_prob() < 0.5) {
                    if (*xpos_m <= 8) (*xpos_m)++;
                }
                else {
                    if (*xpos_m >= 1) (*xpos_m)--;
                }
            }
            else {
                if (get_prob() < 0.5) {
                    if (*ypos_m <= 8) (*ypos_m)++;
                }
                else {
                    if (*ypos_m >= 1) (*ypos_m)--;
                }
            }
        }
        else {   // Ä³¸¯ÅÍ µû¶ó°¨
            *xpos_m = *xpos_m > xpos ? --(*xpos_m) : *xpos_m < xpos ? ++(*xpos_m) : *xpos_m;
            *ypos_m = *ypos_m > ypos ? --(*ypos_m) : *ypos_m < ypos ? ++(*ypos_m) : *ypos_m;
        }
    }
}
 
int main(void)
{
    char board[10][10];
    int xpos = 1, ypos = 1;
    int xpos_m[NUM_MONSTER], ypos_m[NUM_MONSTER];
 
    int xpos_g = 9, ypos_g = 9;
    int score = 0;
    int num = 0, ch=0, flag=0;
 
    CursorView();
    srand(time(NULL));
 
    // º¸µå¸¦ ÃʱâÈ­ÇÑ´Ù. 
    for (int y = 0; y < 10; y++)
        for (int x = 0; x < 10; x++) board[y][x] = '.';
    for (int i = 0; i < NUM_MONSTER; i++) {
        xpos_m[i] = rand() % 10;
        ypos_m[i] = rand() % 10;
    }
    board[ypos][xpos] = '#';
    board[ypos_g][xpos_g] = 'G';
    for (int i = 0; i < NUM_MONSTER; i++) {
        board[ypos_m[i]][xpos_m[i]] = 'M';
    }
 
    printf("¿ÞÂÊÀ̵¿:a, ¿À¸¥ÂÊ À̵¿:d À§ÂÊ À̵¿:w, ¾Æ·¡ÂÊ À̵¿:s\n");
    // »ç¿ëÀڷκÎÅÍ À§Ä¡¸¦ ¹Þ¾Æ¼­ º¸µå¿¡ Ç¥½ÃÇÑ´Ù. 
    while (1) {
        system("cls");
        printf("¿ÞÂÊÀ̵¿:a, ¿À¸¥ÂÊ À̵¿:d À§ÂÊ À̵¿:w, ¾Æ·¡ÂÊ À̵¿:s (%d)\n", num++);
        for (int y = 0; y < 10; y++) {
            for (int x = 0; x < 10; x++printf("%c", board[y][x]);
            printf("\n");
        }
        for (int i = 0 ; i < NUM_MONSTER; i++) {
            if (ypos == ypos_m[i] && xpos == xpos_m[i]) {
                printf("ij¸¯ÅÍ Á×À½ (Á¡¼ö:%d)", score);
                flag = 1;
                break;
            }            
        }
        if (flag == 1break;
        if (ypos == ypos_g && xpos == xpos_g) {
            printf("°ÔÀÓÁ¾·á (Á¡¼ö:%d)", score);
            break;
        }
        board[ypos][xpos] = '.';
        for (int i = 0; i < NUM_MONSTER; i++) {
            board[ypos_m[i]][xpos_m[i]] = '.';
        }
 
        
        if (_kbhit() == 1) {
            ch = _getch();
            //if (ch == 0) ch = _getch();  // Çѹø ÀÔ·ÂÇصµ µÎ¹ø° 0ÀÌ ¶Ç ÀԷµǴ ¹®Á¦ ÇØ°á
 
            if (ch == 'a') { if (xpos >= 1) xpos--; }
            else if (ch == 's') { if (ypos <= 8) ypos++; }
            else if (ch == 'w') { if (ypos >= 1) ypos--; }
            else if (ch == 'd') { if (xpos <= 8) xpos++; }
        }
 
        for (int i = 0; i < NUM_MONSTER; i++) {
                move_monster(xpos, ypos, &xpos_m[i], &ypos_m[i]);
        }
 
        board[ypos][xpos] = '#';
        for (int i = 0; i < NUM_MONSTER; i++) {
            board[ypos_m[i]][xpos_m[i]] = 'M';
        }
        board[ypos_g][xpos_g] = 'G';
        score++;
            
        Sleep(200);
    }
    return 0;
}
 
cs

  µî·ÏÀÏ : 2023-05-26 [20:00] Á¶È¸ : 338 ´Ù¿î : 0   
 
¡â ÀÌÀü±Ûstring1.c (±³Àç)
¡ä ´ÙÀ½±Û(9Àå) Æ÷ÀÎÅÍ ¼ö¾÷ ¼³¸í ¿¹Á¦ ÇÁ·Î±×·¥
ÇÁ·Î±×·¡¹Ö¾ð¾î ½Ç½À°Ô½ÃÆÇ
¹øÈ£ ¨Ï Á¦ ¸ñ Á¶È¸ µî·ÏÀÏ
Mini Project (¾îµåº¥Ã³ °ÔÀÓ ¸¸µé±â) Ãß°¡ ±¸Çö // ¡Ú¡Ú¡Ú ±â¸»°úÁ¦ °ÔÀÓ±¸Çö ½Ã Âü°í
½Ç½À ¸ñÂ÷
201 ¦¦❶ Mini Project (¾îµåº¥Ã³ °ÔÀÓ ¸¸µé±â) 1681 04-24
200    ¦¦❷ Mini Project (¾îµåº¥Ã³ °ÔÀÓ ¸¸µé±â) (¸ð¹ü ´ä¾È) 477 04-24
199       ¦¦❸ Mini Project (¾îµåº¥Ã³ °ÔÀÓ ¸¸µé±â) Ãß°¡ ±¸Çö // ¡Ú¡Ú¡Ú ±â¸»°úÁ¦ °ÔÀÓ±¸Çö ½Ã Âü... 338 05-26
198 ¦¦❶ ¨ÕÃß°¡ µµÀü ¹®Á¦ 1 174 05-12
197    ¦¦❷ Ãß°¡ µµÀü ¹®Á¦ 1 (¸ð¹ü ´ä¾È) 85 05-12
196 ¦¦❶ ¹è¿­À» ÀÌ¿ëÇÑ È£Ãâ ¿¹Á¦µé 298 05-26
195    ¦¦❷ ¹è¿­À» ÀÌ¿ëÇÑ È£Ãâ (1) 374 05-26
194       ¦¦❸ ¹è¿­À» ÀÌ¿ëÇÑ È£Ãâ (2) 390 05-26
193          ¦¦❹ ¹è¿­À» ÀÌ¿ëÇÑ È£Ãâ (3) 376 05-26
192 ¦¦❶ lp_func.c (±³Àç) 872 02-22
191 ¦¦❶ lp_array2.c (±³Àç) 794 02-22
190 ¦¦❶ lp_array1.c (±³Àç) 741 02-22
189 ¦¦❶ lswap2.c (±³Àç) 857 02-22
188 ¦¦❶ lswap1.c (±³Àç) 803 02-22
187 ¦¦❶ lcall_by_ref.c (±³Àç) 714 02-22
186 ¦¦❶ lcall_by_value.c (±³Àç) 1044 02-22
185 ¦¦❶ lpointer_arith1.c (±³Àç) 798 02-22
184 ¦¦❶ lpointer2.c (±³Àç) 795 02-22
183 ¦¦❶ lpointer1.c (±³Àç) 810 02-22
182 ¦¦❶ laddress_of.c (±³Àç) 856 02-22

[1][2][3][4][5][6][7][8][9][10]-[Next][15]