Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Week10] String - 은영 #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions 10-String/2rlo/10798.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// BOJ 10798 세로 읽기

#include <iostream>
#include <string>
using namespace std;

int main()
{
ios_base ::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

string str[5];
for(int i=0; i<5; i++){
cin >> str[i];
}

for(int i=0; i<15; i++){
for(int j=0; j<5; j++){
if(i<str[j].size()){
cout << str[j][i];
}
}
}

return 0;
}
48 changes: 48 additions & 0 deletions 10-String/2rlo/17609.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// BOJ 17609 회문

#include <iostream>
#include <string>
using namespace std;

int palindrome(string s, int check)
{
int left, right;
left = 0;
right = s.size() - 1;

while (left < right)
{
if (s[left] != s[right])
{
if (check == 0)
{
int len = right - left;
if (palindrome(s.substr(left + 1, len), 1) == 0 || palindrome(s.substr(left, len), 1) == 0)
return 1;
else
return 2;
}
else
return 2;
}
left++;
right--;
}
return 0;
}
int main()
{
ios_base ::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

int T;
cin >> T;

for(int i=0; i<T; i++){
string s;
cin >> s;
cout << palindrome(s, 0) << "\n";
}
return 0;
}
32 changes: 32 additions & 0 deletions 10-String/2rlo/20291.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// BOJ 20291 파일 정리

#include <iostream>
#include <string>
#include <map>
using namespace std;

int main()
{
ios_base ::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

int N;
string s;
map<string, int> ex;

cin >> N;
for (int i = 0; i < N; i++)
{
cin >> s;
s = s.substr(s.find('.') + 1);
ex[s]++;
}

for (auto it = ex.begin(); it != ex.end(); it++)
{
cout << (*it).first << " " << (*it).second << "\n";
}

return 0;
}
38 changes: 38 additions & 0 deletions 10-String/2rlo/6550.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// BOJ 6550 부분 문자열

#include <iostream>
#include <string>
using namespace std;

int main()
{
ios_base ::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

string s, t;

while (cin >> s >> t)
{
bool res = false;
int idx = 0;

for (int i = 0; i < t.size(); i++)
{
if (s[idx] == t[i])
idx++;
if (idx == s.length())
{
res = true;
break;
}
}

if (res)
cout << "Yes\n";
else
cout << "No\n";
}

return 0;
}
Loading