Skip to content

Commit

Permalink
6차시 업로드
Browse files Browse the repository at this point in the history
  • Loading branch information
YIM2UL2ET committed Feb 27, 2024
1 parent 92a10e8 commit 6ae28fe
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions YIM2UL2ET/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
| 3차시 | 2024.02.18 | 스택 | [BOJ 2504](https://www.acmicpc.net/problem/2504) | [BOJ 2504 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/9) |
| 4차시 | 2024.02.21 || [BOJ 1021](https://www.acmicpc.net/problem/1021) | [BOJ 1021 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/12) |
| 5차시 | 2024.02.21 || [BOJ 1158](https://www.acmicpc.net/problem/1158) | [BOJ 1158 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/16) |
| 5차시 | 2024.02.21 | 정렬 | [BOJ 1599](https://www.acmicpc.net/problem/1599) | [BOJ 1599 풀이](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/21) |
---
36 changes: 36 additions & 0 deletions YIM2UL2ET/정렬/6차시 - BOJ 1599.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>
#include <algorithm>

std::string change_string(std::string str)
{
int delay = 0;
std::string new_str = str;
for (int i = 0; i < str.size(); i++) {
if (str[i] == 'k') new_str[i-delay] = 'c';
else if (str[i] > 'n') new_str[i-delay]++;
else if (str[i] == 'n' && i+1 < str.size() && str[i+1] == 'g') {
new_str.erase(new_str.begin() + (i++) - delay);
new_str[i - (++delay)] = 'o';
}
}
return new_str;
}

bool compare(std::string str1, std::string str2)
{
return change_string(str1) < change_string(str2);
}

int main(void)
{
int n;
std::cin >> n;

std::string str[n];
for (int i = 0; i < n; i++) std::cin >> str[i];

std::sort(str, str+n, compare);

for (int i = 0; i < n; i++) std::cout << str[i] << std::endl;
return 0;
}

0 comments on commit 6ae28fe

Please sign in to comment.