본문 바로가기

c++86

[프로그래머스] 공배수(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181936 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; int solution(int number, int n, int m) { if(number%n==0&&number%m==0){ return 1; } else{ return 0; } } number이 n과 m으로 나누었을때 모두 나머지가 0이라면 number은 n,m의 공배수 이다. 끝 2023. 12. 27.
[프로그래머스] 문자열 겹쳐쓰기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181943 답 #include #include using namespace std; string solution(string my_string, string overwrite_string, int s) { for(int i=0;i 2023. 12. 26.
[프로그래머스] 문자열 섞기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181942 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include using namespace std; string solution(string str1, string str2) { string ans=""; for(int i=0;i 2023. 12. 26.
[프로그래머스] 문자 리스트를 문자열로 변환하기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181941 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; string solution(vector arr) { string ans; for(int i=0;i 2023. 12. 26.
[프로그래머스] 두 수의 연산값 비교하기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181938 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include using namespace std; int solution(int a, int b) { string a1=to_string(a); string b1=to_string(b); return max(stoi(a1+b1),2*a*b); } 이번 문제는 "더 크게 합치기"와 비슷한 유형의 문제이다. ​ 입력된 정수 a,b를 문자열로 바꾸어 저장한다. (to_string(_)사용) 문.. 2023. 12. 26.
[프로그래머스] 더 크게 합치기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181939 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include using namespace std; int solution(int a, int b) { int ans1=0,ans2=0; string a1=to_string(a); string b1=to_string(b); return max(stoi(a1+b1),stoi(b1+a1)); } ans1과 ans2를 만들었지만 사용하지 않았다. ​ 입력된 정수a,b를 문자열로 바꾸어 준다. (.. 2023. 12. 26.