본문 바로가기

c++86

[프로그래머스] 문자열 곱하기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181940 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; string solution(string my_string, int k) { string ans; for(int i=0;i 2023. 12. 26.
[프로그래머스] 홀수 vs 짝수(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181887 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include using namespace std; int solution(vector num_list) { int ans1=0,ans2=0; for(int i=0;i 2023. 12. 26.
[프로그래머스] 문자열로 변환(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181845?language=cpp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include using namespace std; string solution(int n) { // return 값은 malloc 등 동적 할당을 사용해주세요. 할당 길이는 상황에 맞게 변경해주세요. return to_string(n); } 정수 n을 입력받고 숫자를 문자열로 바꿔어 주는 함수인 to_string을 사용했다. ​ 참고로 문자열을 숫자로 바꿀때는sto.. 2023. 12. 26.
[프로그래머스] n의 배수(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181937 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; int solution(int num, int n) { int answer = 0; if(num%n==0){ answer=1; } else{ answer=0; } return answer; } num을 n으로 나누었을때 나머지가 0이라면 num은 n의 배수 이다. 끝 2023. 12. 26.
[프로그래머스] 홀짝 구분하기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181944 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; if(n%2==0){ cout 2023. 12. 26.
[프로그래머스] 문자열 돌리기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181945 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string s; cin>>s; for(int i=0;i 2023. 12. 26.