#include <iostream>
using namespace std;
void Print(const int a, const int b, const int c)
{
for (int j = 0; j < c; ++j)
{
for (int i = a; i <= b; ++i)
{
cout << i << ' ';
}
cout << endl;
}
}
int main()
{
//Input
int a, b, c;
cin >> a >> b >> c;
Print(a, b, c);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
//Input
char base = 'A';
char board[6][3] = { 0 };
for (int x = 2; x >= 0; x--)
{
for (int y = 5; y >= 0; y--)
{
board[y][x] = base++;
}
}
int x, y;
cin >> x >> y;
cout << board[x][y];
return 0;
}
#include <iostream>
using namespace std;
int arrA[6] = { 0 };
int arrB[2][3];
void FindMin(int& x, int& y)
{
int min = INT_MAX;
for (int i = 0; i < 2; ++(i))
{
for (int j = 0; j < 3; ++(j))
{
if (arrB[i][j] <= min)
{
x = i;
y = j;
min = arrB[i][j];
}
}
}
}
void FindMax(int& x, int& y)
{
int max = INT_MIN;
for (int i = 0; i < 2; ++(i))
{
for (int j = 0; j < 3; ++(j))
{
if (max <= arrB[i][j])
{
x = i;
y = j;
max = arrB[i][j];
}
}
}
}
int main()
{
//Input
for (int i = 0; i < 6; ++i)
{
cin >> arrA[i];
}
for (int i = 0; i < 2; ++i)
{
for (int j = 0; j < 3; ++j)
{
arrB[i][j] = arrA[i * 3 + j];
}
}
// Solve & Print
int x, y;
FindMax(x, y);
cout << "(" << x << ", " << y << ")" << endl;
FindMin(x, y);
cout << "(" << x << ", " << y << ")" << endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
// Input
int arr[6] = { 0 };
cin >> arr[0] >> arr[1];
// Solve
for (int i = 1; i < 6 - 1; ++i)
{
arr[i + 1] = arr[i] * arr[i - 1];
}
// Output
cout << arr[5];
return 0;
}
#include <iostream>
using namespace std;
int main()
{
// Input
char str[100];
cin >> str;
char a, b;
cin >> a >> b;
// Solve
for (char& d : str)
{
if (d == a)
{
d = b;
}
if (d == '\0') break;
}
// Output
cout << str;
return 0;
}
#include <iostream>
using namespace std;
int FindMax(char* str)
{
int max = str[0];
int ret = 0;
for (int i = 1; str[i] != '\0'; ++i)
{
if (max < str[i])
{
max = str[i];
ret = i;
}
}
return ret;
}
int FindMin(char* str)
{
int min = str[0];
int ret = 0;
for (int i = 1; str[i] != '\0'; ++i)
{
if (str[i] < min)
{
min = str[i];
ret = i;
}
}
return ret;
}
int main()
{
// Input
char str[100];
cin >> str;
// Solve
cout << FindMax(str) << endl;
cout << FindMin(str) << endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
// Input
int arr[7][4];
int cnt = 1;
for (int i = 0; i < 7; ++i)
{
for (int j = 0; j < 4; ++j)
{
arr[i][j] = cnt++;
}
}
// Solve
int iArr[3] = { 0 };
for (int i = 0; i < 3; ++i)
{
cin >> iArr[i];
memset(arr + iArr[i], 0, sizeof(int) * 4);
}
// Print
for (int i = 0; i < 7; ++i)
{
for (int j = 0; j < 4; ++j)
{
cout << arr[i][j] << ' ';
}
cout << endl;
}
return 0;
}
#include <iostream>
using namespace std;
char arr[2][6]{
{'A','7','9','T','K','Q'},
{'M','I','N','C','O','D'}
};
bool IsExist(char c)
{
for (int i = 0; i < 2; ++i)
{
for (int j = 0; j < 6; ++j)
{
if (arr[i][j] == c)
{
return true;
}
}
}
return false;
}
int main()
{
// Input
char a, b;
cin >> a >> b;
// Solve & Print
cout << (IsExist(a) ? "존재" : "없음") << endl;
cout << (IsExist(b) ? "존재" : "없음") << endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
// Input
int a, b;
char c;
cin >> a >> b >> c;
// Solve & Print
for (int i = 0; i < a; ++i)
{
for (int j = 0; j < 2; ++j)
{
for (int k = 0; k < b; ++k)
{
cout << c;
}
cout << endl << endl;
}
}
return 0;
}
#include <iostream>
using namespace std;
void StrCpy(char* to, const char* from)
{
int i;
for (i = 0; from[i] != '\0'; ++i)
{
to[i] = from[i];
}
to[i] = '\0';
return;
}
struct Weapon
{
Weapon() = default;
Weapon(const char* str)
{
StrCpy(mName, str);
}
char mName[100] = { 0 };
};
class Player
{
public:
Player() = default;
Player(const Player&) = default;
~Player() = default;
void PrintInfo()
{
cout << mName << endl;
cout << "hp : " << mHp << endl;
cout << "weapon : " << mWeapon.mName << endl;
return;
}
void SetName(const char* name)
{
StrCpy(mName, name);
}
void SetHp(int hp)
{
mHp = hp;
}
void SetWeapon(Weapon weapon)
{
mWeapon = weapon;
}
private:
char mName[100] = { 0 };
int mHp;
Weapon mWeapon = Weapon();
};
int main()
{
// Input
Player a;
a.SetName("warrior");
a.SetHp(200);
a.SetWeapon(Weapon("sword"));
Player b;
b.SetName("archer");
b.SetHp(100);
b.SetWeapon(Weapon("bow"));
// Output
a.PrintInfo();
b.PrintInfo();
return 0;
}
'코딩 테스트 > 알고리즘 풀이' 카테고리의 다른 글
[LV3] 복습 문제 (0) | 2025.04.15 |
---|---|
[LV3] 연습 문제 (0) | 2025.04.14 |
[LV1] 연습 문제 (0) | 2025.04.12 |
[알고스팟 - TRIANGLEPATH] 삼각형 위의 최대 경로 (0) | 2023.01.08 |
[알고스팟 - QUADTREE] 쿼드 트리 뒤집기 (0) | 2022.12.10 |