ÀÚ¹Ù º¼¸µ°è»ê ÇÁ·Î±×·¥ÀÔ´Ï´Ù.
ÀÌ ¼Ò½º¿¡¼ '¿£ÅÍ' ÀÔ·Â ½Ã, ÇÁ·Î±×·¥À» Á¾·á½ÃÅ°´Â ±â´ÉÀ» Ãß°¡ÇÏ°í ½ÍÀºµ¥ ¾î¶»°Ô ÇؾßÇÒ±î¿ä?
Á¶¾ðÁ» ºÎŹµå¸³´Ï´Ù.¤Ð¤Ð..
import java.util.Scanner;
public class game {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[][] arr = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
int i, k, b, c;
int per = 0; // ¼±¼ö
int srk = 0; // ½ºÆ®¶óÀÌÅ©
int spa = 0; // ½ºÆä¾î
int bon = 0; // º¸³Ê½º
int sco = 0;
int count = 1;
System.out.print("°ÔÀÓ ¼ö ÀÔ·Â : ");
per = input.nextInt();
for (k = 0; k < per; k++) {
System.out.println((k + 1) + "¹ø° °ÔÀÓ ½ÃÀÛ!!");
for (i = 0; i < 10; i++) {
System.out.println("< " + (i + 1) + " ¹ø° ÇÁ·¹ÀÓ >\n");
arr[0][i] = i + 1;
System.out.printf(" * 1±¸ : ");
arr[1][i] = input.nextInt();
if (arr[1][i] > 10 || arr[1][i] + arr[2][i] > 11) {
System.out.println("´Ù½Ã ÀÔ·ÂÇØÁÖ¼¼¿ä!");
arr[1][i] = 0;
System.out.printf(" * 1±¸ : ");
arr[1][i] = input.nextInt();
}
if (arr[1][i] < 10) {
System.out.printf(" * 2±¸ : ");
arr[2][i] = input.nextInt();
if (arr[2][i] > 10 || arr[1][i] + arr[2][i] > 11) {
System.out.println("´Ù½Ã ÀÔ·ÂÇØÁÖ¼¼¿ä!");
arr[2][i] = 0;
System.out.printf(" * 2±¸ : ");
arr[2][i] = input.nextInt();
}
}
System.out.println();
if (arr[1][i] == 10) {
srk = 1;
}
if (((srk == 0) && ((arr[1][i] + arr[2][i]) == 10))) // ½ºÆä¾î
{
spa = 1;
}
if ((i == 9) && (arr[1][i] == 10)) // 10 ÇÁ·¹ÀÓ 1ȸ ½ºÆ®¶óÀÌÅ© + 2ȸ º¸³Ê½º
{
System.out.printf(" * º¸³Ê½º : ");
bon = input.nextInt();
arr[2][i] += bon;
if (arr[2][i] > 0) // ½ºÆä¾î ½Ã
{
System.out.printf(" * º¸³Ê½º : ");
bon = input.nextInt();
arr[2][i] += bon;
spa = 1;
}
}
if ((i == 9) && ((arr[1][i] + arr[2][i]) == 10)) {
System.out.printf(" * º¸³Ê½º : ");
bon = input.nextInt();
arr[2][i] += bon;
}
////////////////////////////////////////////////////////////////////////// Á¡¼ö°è»ê
if (i == 0) {
arr[3][i] = arr[1][i] + arr[2][i];
} else if (((arr[1][i - 1] == 10) && (arr[2][i - 1] == 0)) && (i > 0)) // ½ºÆ®¶óÀÌÅ©
// Á¡¼ö
// °è»ê
{
{
arr[3][i - 1] += arr[1][i] + arr[2][i];
}
arr[3][i] = arr[1][i] + arr[2][i] + arr[3][i - 1];
srk = 0;
} else if (((arr[1][i - 1] > 0) || (arr[2][i - 1] > 0)) && (arr[1][i - 1] + arr[2][i - 1]) == 10) {
arr[3][i - 1] += arr[1][i];
arr[3][i] = arr[1][i] + arr[2][i] + arr[3][i - 1];
spa = 0;
} else {
arr[3][i] = arr[1][i] + arr[2][i] + arr[3][i - 1];
}
////////////////////////////////////////////////////////////////////////// Á¡¼ö
////////////////////////////////////////////////////////////////////////// Ãâ·Â
// System.out.printf((k+1) + " ¹ø° °ÔÀÓ ½ÃÀÛ!! \n");
for (b = 0; b < 4; b++) {
if (i + 2 <= 10) {
arr[0][i + 1] = i + 2;
}
if (b == 0) {
System.out.printf(" ÇÁ·¹ÀÓ ");
} else if (b == 1) {
System.out.printf(" < 1 > ");
} else if (b == 2) {
System.out.printf(" < 2 > ");
} else {
System.out.printf(" ÇÕ °è ");
}
for (c = 0; c < 10; c++) {
System.out.print("\t" + arr[b][c]);
}
if (b == 1 || b == 3) {
System.out.printf("\n");
} else {
System.out.printf("\n\n");
}
}
if (srk == 1) // ½ºÆ®¶óÀÌÅ©, ½ºÆä¾î Á¡¼ö ó¸® : ´ÙÀ½ ÇÁ·¹ÀÓ °ÔÀÓ ÇÑÈÄ ÇÕ»ê
{
if (i == 0) {
} else {
arr[3][i - 1] += arr[1][i + 1] + arr[2][i + 1];
srk = 0;
}
} else if (spa == 1) {
if (i == 0) {
} else {
arr[3][i - 1] += arr[1][i + 1];
spa = 0;
}
}
System.out.println("\n");
}
}
if (arr[3][9] > sco) {
sco = arr[3][9];
count = k;
}
for (b = 0; b < 4; b++) {
for (c = 0; c < 10; c++) {
arr[b][c] = 0;
}
}
System.out.print("1 µî : " + count + "¹ø° °ÔÀÓ");
System.out.println(", " + sco + "Á¡ µæÁ¡!!");
}
}<!--"<--> | |
|