char path[10] = "";
char name[10] = "ABC";
void Recursive(int level)
{
if (level == 2)
{
std::cout << path << endl;
return;
}
for (size_t i = 0; i < 3; i++)
{
path[level] = name[i]; // 이 함수의 level
Recursive(level + 1);
path[level] = 0;
}
}
int main()
{
Recursive(0);
return 0;
}
int main()
{
char strings[3][11];
for (auto& d : strings)
{
cin >> d;
}
int cnt = 0;
if (strcmp(strings[0], strings[1]) == 0) ++cnt;
if (strcmp(strings[0], strings[2]) == 0) ++cnt;
if (strcmp(strings[1], strings[2]) == 0) ++cnt;
if (3 <= cnt) cout << "WOW";
else if (2 <= cnt) cout << "GOOD";
else if (cnt <= 0) cout << "BAD";
return 0;
}
char path[10] = { 0 };
char name[10] = "BGTK";
int cMaxLevel = 0;
void Recursive(int level)
{
if (level == cMaxLevel)
{
cout << path << endl;
return;
}
for (int i = 0; i < 4; ++i)
{
path[level] = name[i];
Recursive(level + 1);
}
}
int main()
{
cin >> cMaxLevel;
Recursive(0);
return 0;
}
char cmds[5][6] = { 0 };
int currentPos = 0;
int main()
{
for (auto& d : cmds)
{
cin >> d;
if (strcmp(d, "up") == 0) ++currentPos;
if (strcmp(d, "down") == 0) --currentPos;
}
if (currentPos < 0)
{
currentPos *= -1;
cout << "B";
}
else ++currentPos;
cout << currentPos;
return 0;
}
char path[10] = { 0 };
int n = 0;
void Recursive(int level)
{
if (level == 4)
{
cout << path << endl;
return;
}
for (int i = 1; i <= n; ++i)
{
path[level] = (i + '0');
Recursive(level + 1);
}
}
int main()
{
cin >> n;
Recursive(0);
return 0;
}
string strs[4];
int main()
{
int max = -1, min = 999;
int maxIdx, minIdx;
for (int i = 0; i <4; ++i)
{
cin >> strs[i];
int length = strs[i].length();
if (max < length)
{
max = length;
maxIdx = i;
}
if (length < min)
{
min = length;
minIdx = i;
}
}
cout << "긴 문장 : " << maxIdx << endl;
cout << "짧은 문장 : " << minIdx;
return 0;
}
char toFind[4] = { 0 };
// 특정 경로를 찾는 함수
char path[4] = { 0 };
char pathName[5] = "ABCD";
int cnt = 0;
bool Recursive(int level)
{
// BaseCase
if (level == 3)
{
++cnt;
if (strcmp(toFind, path) == 0)
{
return true;
}
return false;
}
// Body
for (int i = 0; i < 4; ++i)
{
path[level] = pathName[i];
if (Recursive(level + 1) == true) return true;
}
return false;
}
int main()
{
cin >> toFind;
Recursive(0);
cout << cnt;
return 0;
}
int arr[3][2][2] = {
2,4,1,5,2,3,3,6,7,3,1,5
};
int main()
{
int n; cin >> n;
int max = -1;
int min = 10;
for (int i = 0; i < 2; ++i)
{
for (int j = 0; j < 2; ++j)
{
int t = arr[n][i][j];
if (max < t) max = t;
if (t < min) min = t;
}
}
cout << "MAX = " << max << endl;
cout << "MIN = " << min << endl;
return 0;
}
char arr[5][10] = {
"Jason",
"Dr.tom",
"EXEXI",
"GK12P",
"POW"
};
int main()
{
char str[10];
cin >> str;
for (char(&d)[10] : arr)
{
if (strcmp(str, d) == 0)
{
cout << "암호해제";
return 0;
}
}
cout << "암호틀림";
return 0;
}
'코딩 테스트 > 알고리즘 풀이' 카테고리의 다른 글
[배열편] 코테 준비 문제 (0) | 2025.05.06 |
---|---|
[LV7] 복습 문제 (0) | 2025.05.02 |
[LV6] 복습 문제 (0) | 2025.04.27 |
[LV6] 연습 문제 (0) | 2025.04.26 |
[LV5] 훈련 문제 (0) | 2025.04.21 |