Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <windows.h>
- #include <stdlib.h>
- #include <time.h>
- int dice(int num) {
- if (num == 0) {
- printf(" ");
- }
- else if (num == 1) {
- printf("●");
- }
- }
- int main() {
- int i, j, r1, r2;
- int player, com;
- const int Dice[6][3][3] = {
- {{0,0,0},{0,1,0},{0,0,0}},
- {{0,0,1},{0,0,0},{1,0,0}},
- {{0,0,1},{0,1,0},{1,0,0}},
- {{1,0,1},{0,0,0},{1,0,1}},
- {{1,0,1},{0,1,0},{1,0,1}},
- {{1,0,1},{1,0,1},{1,0,1}}
- };
- while (1) {
- system("cls");
- srand((unsigned int)time(NULL));
- printf("\n 주사위를 굴리는 중입니다...!");
- Sleep(1000);
- system("cls");
- printf("\n");
- printf(" ┌────────────────────────────┐\n");
- printf(" │ │\n");
- r1 = rand() % 6;
- r2 = rand() % 6;
- player = r1 + r2 + 2;
- printf(" │ ┌───────┐┌───────┐ │\n");
- for (i = 0; i < 3; i++) {
- printf(" │ │ ");
- for (j = 0; j < 3; j++) {
- dice(Dice[r1][i][j]);
- }
- printf("││ ");
- for (j = 0; j < 3; j++) {
- dice(Dice[r2][i][j]);
- }
- printf("│ │\n");
- }
- printf(" │ └───────┘└───────┘ │\n");
- printf(" │ │\n");
- printf(" │ 당신의 주사위 합계 : %2d │ \n", player);
- printf(" │ │\n");
- printf(" ├────────────────────────────┤\n");
- r1 = rand() % 6;
- r2 = rand() % 6;
- com = r1 + r2 + 2;
- printf(" │ │\n");
- printf(" │ ┌───────┐┌───────┐ │\n");
- for (i = 0; i < 3; i++) {
- printf(" │ │ ");
- for (j = 0; j < 3; j++) {
- dice(Dice[r1][i][j]);
- }
- printf("││ ");
- for (j = 0; j < 3; j++) {
- dice(Dice[r2][i][j]);
- }
- printf("│ │\n");
- }
- printf(" │ └───────┘└───────┘ │\n");
- printf(" │ │\n");
- printf(" │ 컴퓨터의 주사위 합계 : %2d │\n", com);
- printf(" │ │\n");
- printf(" └────────────────────────────┘\n");
- if (player > com) {
- printf(" 플레이어가 이겼습니다!");
- }
- else if (player < com) {
- printf(" 컴퓨터가 이겼습니다...");
- }
- else {
- printf(" 서로 비겼습니다!");
- }
- system("pause > nul");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement