회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
예제는 정확하게 실행결과가 나오는데 틀리네요..
2941번 - 크로아티아 알파벳
jinkor
7년 전
0
도움이 절실합니다..!!
문제에 있는 예제말고 다른게 없으니 확인할 방법이 없네요...
#include <string> #include <iostream> #include <vector> using namespace std; int main() { vector<string> alphaList; alphaList.push_back("c="); alphaList.push_back("c-"); alphaList.push_back("dz="); alphaList.push_back("d-"); alphaList.push_back("lj"); alphaList.push_back("nj"); alphaList.push_back("s="); alphaList.push_back("z="); //특수문자 등록 string str; cin >> str; int count = 0; //특수문자 카운팅 for (string ele : alphaList) { size_t nPos = str.find(ele, 0); while (nPos != string::npos) { count += 1; nPos = str.find(ele, nPos+1); } } //특수문자를 |로 치환 for (string ele : alphaList) { size_t nPos = str.find(ele, 0); while (nPos != string::npos) { string dum; for (int i = 0; i < ele.size(); i++) { dum.push_back('|'); } str.replace(str.find(ele),ele.size(),dum); nPos = str.find(ele,0); } //cout << "ele : " << ele << endl; //cout << "str : " << str << endl; //cout << endl; } //|,-,= 삭제 while (str.find('|') != string::npos) { str.replace(str.find('|'), 1, ""); } while (str.find('-') != string::npos) { str.replace(str.find('-'), 1, ""); } while (str.find('=') != string::npos) { str.replace(str.find('='), 1, ""); } //cout <<"str : "<< str << endl; //나머지 일반 알파벳 [a-z]를 사이즈에 추가 count += str.size(); cout << count << endl; };
sung1104hyun
7년 전
0
dz= 넣으면 1이나와야하는데 2가 나오네용
댓글을 작성하려면
로그인
해야 합니다.
jinkor 7년 전
도움이 절실합니다..!!
문제에 있는 예제말고 다른게 없으니 확인할 방법이 없네요...