Q) ๊ณก์ ์ด 9ํ์ด ์๊ณ , ํ๋ง๋ค ์ผ์ ์ธ์์ ๋ฉค๋ฒ๊ฐ ์๋๋ฐ ์ธ๋ถ๊ณต์ฐ์ ๋ฑ ์ซ์๋ฅผ ๋ง์ถฐ ์ธ์์ ๋ณด๋ด์ผํ๊ธฐ์, ์ด๋ค ํ์ ๋ณด๋ด์ผ ์ซ์๊ฐ ๋ฑ ๋ง๋์ง ์์๋ด์ผํ๋ค.
๊ทธ๋ฌ๋ ํ๋ง๋ค ๋ฉค๋ฒ๊ฐ ๊ฒน์น๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ ํ๋ํ๋ ์์ผ๋ก ๋ฐ์ ธ๊ฐ๊ธฐ๋ณด๋ค๋ ์ฝ๋ฉ์ด ํธํ ๊ฒ ๊ฐ์ ์ฝ๋ฉํด๋ดค๋ค.
์ฝ๋๋ ๋๋ต 300์ค ์ ๋ ๋์จ๋ค.
๋จผ์ ์ฌ๋๋ง๋ค ์ผ์ ํ ์ฝ๋'a~e, A~Z๊น์ง ์ด 31๊ฐ'๋ฅผ ๋ถ์ฌํ ํ, ํ๋ง๋ค ๋ฉค๋ฒ๋ฅผ ์ฝ๋๋ฅผ ์ฌ์ฉํด ์ ๋ฆฌํด๋ณด์๋ค.
Team 1 ๋ค๋ฆฌํฐ (4๋ช ) EPMT
Team 2 ์ ์ (9๋ช ) ABEFINOPM
Team 3 ๋ผ์ด์ธ (6๋ช ) DGNQUV
Team 4 ํ (4๋ช ) FLNQ
Team 5 ์ด๋ฃจ๋ฆฌ (10๋ช ) GPRSQMWXYV
Team 6 ํ๋ผ์์ค์ (10๋ช ) EGHNOUZWXV
Team 7 ์ํ (7๋ช ) ACEHJZT
Team 8 blue flame (8๋ช ) KPQabcVZ
Team 9 ์ต์ธ์ (7๋ช ) CJLdeaZ
์ดํ, strcpy์ strcatํจ์๋ฅผ ์ด์ฉํด ๋ฉค๋ฒ๋ฅผ ํ ๋ฌธ์์ด๋ก ๋ฌถ์ ํ ๊ฒน์น๋ ๋ฌธ์๋ฅผ ๋นผ๋ฒ๋ฆฌ๋ฉด ๋๋ค.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
strcpy(temp, acting[a]);
strcat(temp, acting[b]);
strcat(temp, acting[c]);
leng_before = strlen(temp);
for (i = 0; i < leng_before; i++)
{
for (j = i + 1; j < leng_before; j++)
{
if (temp[i] == temp[j])
{
for (k = j; k < leng_before; k++)
{
temp[k] = temp[k + 1];
}
}
}
}
leng_after = strlen(temp);
if (leng_after <= 20)
{
printf("%s %d\n", temp, leng_after);
}
|
cs |
์ด๋ฐ ํจ์๋ฅผ ์ฌ์ฉํ๋ฉด (๊ฒน์น๋ ๊ณก์์ ํ ๋ช ์ผ๋ก ์ธ์ด์ง๋) ๋ฉค๋ฒ์ ์ ์ฒด ๋ฉค๋ฒ ์ซ์๋ฅผ ๊ตฌํ ์ ์๋ค.
๊ธฐ๋ฅ A์ B๋ฅผ ๋์ ํ์๋๋ฐ ๊ธฐ๋ฅ A๋ Team์ ์ฝ๋๋ฅผ ์ ๋ ฅํ๋ฉด(ex. Team 1, Team 2, Team 3) ๊ฐ Team ๋ง๋ค ๊ฒน์น๋ ๋ฉค๋ฒ๋ฅผ ๊ณ ๋ คํด ์ด ๋ฉค๋ฒ์ ์ซ์๋ฅผ ๊ตฌํด์ค๋ค.
๊ธฐ๋ฅ B๋ ๊ฐ ์ ์๋ Team์ ์์ ์ธ์์ ์ํ์น๋ฅผ ์ ๋ ฅํ๋ฉด(ex. 4ํ์ด ๊ฐ ์ ์๊ณ ์ด 17๋ช ์ดํ๊ฐ ๊ฐ์ผํจ) ๊ฐ๋ฅํ Team์ ์กฐํฉ์ ๋ชจ๋ ๋ณด์ฌ์ค๋ค.
๊ธฐ์๋ณ๋ก ๋ฌธ์๋ค์ ์ฌ์กฐํฉํด ๋ค์ ๋ณด์ฌ์ฃผ๋ ๊ธฐ๋ฅ๋ ์ถ๊ฐํ๋ค
์ฝ๋๋ '๋๋ณด๊ธฐ' ํด๋ฆญ
#define _CRT_SECURE_NO_WARNINGS
#include
#include
void main()
{
char acting[9][20] = {"EPMT", "ABEFINOPM", "DGNQUV", "FLNQ", "GPRSQMWXYV", "EGHNOUZWXV", "ACEHJZT", "KPQabcVZ", "CJLdeAZ"};
char temp[80];
char null[1] = {""};
int leng_before, leng_after;
int a, b, c, d, e, f, i, j, k;
char decide;
char tem;
int team, number;
printf("- Team 1 ๋ค๋ฆฌํฐ (4๋ช
) EPMT\n- Team 2 ์ ์ (9๋ช
) ABEFINOPM\n- Team 3 ๋ผ์ด์ธ (6๋ช
) DGNQUV\n- Team 4 ํ (4๋ช
) FLNQ\n- Team 5 ์ด๋ฃจ๋ฆฌ (10๋ช
) GPRSQMWXYV\n- Team 6 ํ๋ผ์์ค์ (10๋ช
) EGHNOUZWXV\n- Team 7 ์ํ (7๋ช
) ACEHJZT\n- Team 8 blue flame (8๋ช
) KPQabcVZ\n- Team 9 ์ต์ธ์
(7๋ช
) CJLdeAZ\n\n");
printf("๊ธฐ๋ฅ A : ํ์ ์
๋ ฅํ๋ฉด ์ธ์์ ์๋ ค์ค\n๊ธฐ๋ฅ B : ์ธ์์ ์
๋ ฅํ๋ฉด ํ์ ์๋ ค์ค\n\n");
printf("-----------------------\n\n");
while (1)
{
scanf("%c", &decide);
if (decide == 'A')
{
printf("- ํ์ ์
๋ ฅํ๋ฉด ์ธ์์ ์๋ ค์ค\n- ํ์ ์
๋ ฅํ์ธ์\n- 0์ ์
๋ ฅํ๋ฉด ์ข
๋ฃ\n");
strcpy(temp, null);
while (1)
{
scanf("%d", &a);
if (a >= 1 && a <= 9)
{
strcat(temp, acting[a-1]);
}
else
break;
}
leng_before = strlen(temp);
for (i = 0; i < leng_before; i++)
{
for (j = i + 1; j < leng_before; j++)
{
if (temp[i] == temp[j])
{
for (k = j; k < leng_before; k++)
{
temp[k] = temp[k + 1];
}
}
}
}
leng_after = strlen(temp);
printf("\nํ์ : %s , ํ์ ์ซ์ : %d\n", temp, leng_after);
for (i = 0; i < leng_after; i++)
{
for (j = i + 1; j < leng_after; j++)
{
if (temp[i] > temp[j])
{
tem = temp[i];
temp[i] = temp[j];
temp[j] = tem;
}
}
}
printf("๊ธฐ์๋ณ๋ก : %s\n\n", temp);
printf("-----------------------\n\n");
}
else if (decide == 'B')
{
printf("- ์ธ์์ ์
๋ ฅํ๋ฉด ํ์ ์๋ ค์ค\n- nํ์ด ๊ฐ๋ ๊ฒฝ์ฐ n๋ช
์ดํ์ ๊ฒฝ์ฐ์ ์\n");
scanf("%d %d", &team, &number);
if (team == 3)
{
printf("<%dํ์ด ๊ฐ๋ ๊ฒฝ์ฐ %d๋ช
์ดํ ๊ฒฝ์ฐ์ ์> \n\n", 3, number);
for (a = 0; a <= 8; a++)
{
for (b = a + 1; b <= 8; b++)
{
for (c = b + 1; c <= 8; c++)
{
strcpy(temp, acting[a]);
strcat(temp, acting[b]);
strcat(temp, acting[c]);
leng_before = strlen(temp);
for (i = 0; i < leng_before; i++)
{
for (j = i + 1; j < leng_before; j++)
{
if (temp[i] == temp[j])
{
for (k = j; k < leng_before; k++)
{
temp[k] = temp[k + 1];
}
}
}
}
leng_after = strlen(temp);
if (leng_after <= number)
{
printf("ํ์ : %s ๊ฐ๋ ํ : %d %d %d ์ ์ฒด์ธ์ : %d\n", temp, a + 1, b + 1, c + 1, leng_after);
for (i = 0; i < leng_after; i++)
{
for (j = i + 1; j < leng_after; j++)
{
if (temp[i] > temp[j])
{
tem = temp[i];
temp[i] = temp[j];
temp[j] = tem;
}
}
}
printf("๊ธฐ์๋ณ๋ก : %s\n\n", temp);
}
}
}
}
}
else if (team == 4)
{
printf("<%dํ์ด ๊ฐ๋ ๊ฒฝ์ฐ %d๋ช
์ดํ ๊ฒฝ์ฐ์ ์> \n\n", 4, number);
for (a = 0; a <= 8; a++)
{
for (b = a + 1; b <= 8; b++)
{
for (c = b + 1; c <= 8; c++)
{
for (d = c + 1; d <= 8; d++)
{
strcpy(temp, acting[a]);
strcat(temp, acting[b]);
strcat(temp, acting[c]);
strcat(temp, acting[d]);
leng_before = strlen(temp);
for (i = 0; i < leng_before; i++)
{
for (j = i + 1; j < leng_before; j++)
{
if (temp[i] == temp[j])
{
for (k = j; k < leng_before; k++)
{
temp[k] = temp[k + 1];
}
}
}
}
leng_after = strlen(temp);
if (leng_after <= number)
{
printf("ํ์ : %s ๊ฐ๋ ํ : %d %d %d %d ์ ์ฒด์ธ์ : %d\n", temp, a + 1, b + 1, c + 1, d + 1, leng_after);
for (i = 0; i < leng_after; i++)
{
for (j = i + 1; j < leng_after; j++)
{
if (temp[i] > temp[j])
{
tem = temp[i];
temp[i] = temp[j];
temp[j] = tem;
}
}
}
printf("๊ธฐ์๋ณ๋ก : %s\n\n", temp);
}
}
}
}
}
}
else if (team == 5)
{
printf("<%dํ์ด ๊ฐ๋ ๊ฒฝ์ฐ %d๋ช
์ดํ ๊ฒฝ์ฐ์ ์> \n\n", 5, number);
for (a = 0; a <= 8; a++)
{
for (b = a + 1; b <= 8; b++)
{
for (c = b + 1; c <= 8; c++)
{
for (d = c + 1; d <= 8; d++)
{
for (e = d + 1; e <= 8; e++)
{
strcpy(temp, acting[a]);
strcat(temp, acting[b]);
strcat(temp, acting[c]);
strcat(temp, acting[d]);
strcat(temp, acting[e]);
leng_before = strlen(temp);
for (i = 0; i < leng_before; i++)
{
for (j = i + 1; j < leng_before; j++)
{
if (temp[i] == temp[j])
{
for (k = j; k < leng_before; k++)
{
temp[k] = temp[k + 1];
}
}
}
}
leng_after = strlen(temp);
if (leng_after <= number)
{
printf("ํ์ : %s ๊ฐ๋ ํ : %d %d %d %d %d ์ ์ฒด์ธ์ : %d\n", temp, a + 1, b + 1, c + 1, d + 1, e + 1, leng_after);
for (i = 0; i < leng_after; i++)
{
for (j = i + 1; j < leng_after; j++)
{
if (temp[i] > temp[j])
{
tem = temp[i];
temp[i] = temp[j];
temp[j] = tem;
}
}
}
printf("๊ธฐ์๋ณ๋ก : %s\n\n", temp);
}
}
}
}
}
}
}
else if (team == 6)
{
printf("<%dํ์ด ๊ฐ๋ ๊ฒฝ์ฐ %d๋ช
์ดํ ๊ฒฝ์ฐ์ ์> \n\n", 6, number);
for (a = 0; a <= 8; a++)
{
for (b = a + 1; b <= 8; b++)
{
for (c = b + 1; c <= 8; c++)
{
for (d = c + 1; d <= 8; d++)
{
for (e = d + 1; e <= 8; e++)
{
for (f = e + 1; f <= 8; f++)
{
strcpy(temp, acting[a]);
strcat(temp, acting[b]);
strcat(temp, acting[c]);
strcat(temp, acting[d]);
strcat(temp, acting[e]);
strcat(temp, acting[f]);
leng_before = strlen(temp);
for (i = 0; i < leng_before; i++)
{
for (j = i + 1; j < leng_before; j++)
{
if (temp[i] == temp[j])
{
for (k = j; k < leng_before; k++)
{
temp[k] = temp[k + 1];
}
}
}
}
leng_after = strlen(temp);
if (leng_after <= number)
{
printf("ํ์ : %s ๊ฐ๋ ํ : %d %d %d %d %d %d ์ ์ฒด์ธ์ : %d\n", temp, a + 1, b + 1, c + 1, d + 1, e + 1, f + 1, leng_after);
for (i = 0; i < leng_after; i++)
{
for (j = i + 1; j < leng_after; j++)
{
if (temp[i] > temp[j])
{
tem = temp[i];
temp[i] = temp[j];
temp[j] = tem;
}
}
}
printf("๊ธฐ์๋ณ๋ก : %s\n\n", temp);
}
}
}
}
}
}
}
}
printf("-----------------------\n\n");
}
}
}