알고리즘104 프로그래머스 - 자릿수 더하기 (C++) 12345678910111213141516171819#include #include using namespace std; int solution(int n){ int answer = 0; // 숫자를 문자열로 변환 string number_str = to_string(n); // 문자열의 각 자릿수를 다시 숫자로 변환하여 answer에 더함. for(int i = 0; i 2020. 3. 12. 프로그래머스 - 이상한 문자 만들기 (C++) 1234567891011121314151617181920212223242526272829303132333435363738394041424344#include #include using namespace std; // 짝수인덱스 -> 대문자// 홀수인덱스 -> 소문자 string solution(string s) { string answer = ""; // j는 단어의 인덱스 // i는 문자열 전체의 인덱스 for(int i = 0, j = 0; i 2020. 3. 12. 프로그래머스 - 약수의 합 (C++) 12345678910111213141516171819#include #include using namespace std; int solution(int n) { int answer = 0; for(int i = 1; i 2020. 3. 6. 프로그래머스 - 시저 암호 (C++) 123456789101112131415161718192021222324252627#include #include using namespace std; string solution(string s, int n) { for(int i = 0; i 'Z'){ s[i] = 'A' - 1 + ((s[i] + n) % 'Z'); }else{ s[i] += n; } }else if(islower(s[i])){ if(s[i] + n > 'z'){ s[i] = 'a' - 1 + ((s[i] + n) % 'z'); }else{ s[i] += n; } } } return s;}Colored by Color Scriptercs 2020. 3. 6. 이전 1 ··· 20 21 22 23 24 25 26 다음