본문 바로가기

string

(26)
[Programmers] 개인정보 수집 유효기간 (C++) https://school.programmers.co.kr/learn/courses/30/lessons/150370 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; vector solution(string today, vector terms, vector privacies) { vector answer; int today_num = stoi(today.substr(0, 4)) * 12 * 28 + stoi(today.substr(5, 7)) * 28 + stoi(today..
[BOJ] 4949번 균형잡힌 세상 (C++) https://www.acmicpc.net/problem/4949 4949번: 균형잡힌 세상 하나 또는 여러줄에 걸쳐서 문자열이 주어진다. 각 문자열은 영문 알파벳, 공백, 소괄호("( )") 대괄호("[ ]")등으로 이루어져 있으며, 길이는 100글자보다 작거나 같다. 각 줄은 마침표(".")로 끝난다 www.acmicpc.net #include #include #include using namespace std; int main() { while(true){ string str; getline(cin, str); if(str == ".") break; stack st; string ans = "yes"; for(int i = 0; i < str.length(); i++){ if(str[i] == '(..
[BOJ] 1235번 학생 번호 (C++) https://www.acmicpc.net/problem/1235 1235번: 학생 번호 첫째 줄에는 학생의 수 N(2≤N≤1,000)이 주어진다. 둘째 줄부터 N개의 줄에 걸쳐 각 학생의 학생 번호가 순서대로 주어진다. 모든 학생들의 학생 번호는 서로 다르지만 그 길이는 모두 같으며, 0부 www.acmicpc.net #include #include #include using namespace std; int main() { int n; cin >> n; string s[1000]; for(int i = 0; i > s[i]; } int ans = s[0].size(); for(int i = 0; i < s[0].size(); i++){ set st; for(int j = ..
[BOJ] 12813번 이진수 연산 (C++) https://www.acmicpc.net/problem/12813 12813번: 이진수 연산 총 100,000 비트로 이루어진 이진수 A와 B가 주어진다. 이때, A & B, A | B, A ^ B, ~A, ~B를 한 값을 출력하는 프로그램을 작성하시오. www.acmicpc.net #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); char a[100001]; char b[100001]; cin >> a >> b; // A & B for(int i = 0; i < strlen(a); i++){ if(a[i] == '1' && b[i] == '1') cout
[Programmers] 숫자 문자열과 영단어 (C++) https://programmers.co.kr/learn/courses/30/lessons/81301 코딩테스트 연습 - 숫자 문자열과 영단어 네오와 프로도가 숫자놀이를 하고 있습니다. 네오가 프로도에게 숫자를 건넬 때 일부 자릿수를 영단어로 바꾼 카드를 건네주면 프로도는 원래 숫자를 찾는 게임입니다. 다음은 숫자의 일부 자 programmers.co.kr #include #include using namespace std; int solution(string s) { string num[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; string str[10] = {"zero", "one", "two", "three", "four", "five",..
[Programmers] 신규 아이디 추천 (C++) https://programmers.co.kr/learn/courses/30/lessons/72410 코딩테스트 연습 - 신규 아이디 추천 카카오에 입사한 신입 개발자 네오는 "카카오계정개발팀"에 배치되어, 카카오 서비스에 가입하는 유저들의 아이디를 생성하는 업무를 담당하게 되었습니다. "네오"에게 주어진 첫 업무는 새로 programmers.co.kr #include #include using namespace std; string solution(string new_id) { bool flag = false; for(int i = 0; i < new_id.length(); i++){ // 1단계 new_id[i] = tolower(new_id[i]); // 2단계 if(!isdigit(new_id[i..
[BOJ] 1543번 문서 검색 (C++) https://www.acmicpc.net/problem/1543 1543번: 문서 검색 세준이는 영어로만 이루어진 어떤 문서를 검색하는 함수를 만들려고 한다. 이 함수는 어떤 단어가 총 몇 번 등장하는지 세려고 한다. 그러나, 세준이의 함수는 중복되어 세는 것은 빼고 세야 한 www.acmicpc.net #include #include using namespace std; int main() { string s1, s2; getline(cin, s1); getline(cin, s2); int s = 0, cnt = 0; while(1){ int t = s1.find(s2, s); if(t == -1) break; s = t + s2.size(); cnt++; } cout
[BOJ] 21966번 (중략) (C++) https://www.acmicpc.net/problem/21966 21966번: (중략) 알파벳 대문자, 알파벳 소문자, 쉼표, 마침표의 아스키 코드는 각각 65-90, 97-122, 44, 46이다. www.acmicpc.net #include #include using namespace std; int main() { int n; string s; cin >> n >> s; string sub = s.substr(11, n - 22); int in = sub.find("."); if(n