나누어 떨어지는 숫자 배열
https://school.programmers.co.kr/learn/courses/30/lessons/12910
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> arr, int divisor)
{
vector<int> answer;
for (int num : arr)
{
if (!(num % divisor)) //배수가 맞으면
{
answer.push_back(num);
}
}
if (!answer.size()) //size가 0이면 -1 추가
{
answer.push_back(-1);
}
else //size가 0이 아니면 오름차순 정렬
{
sort(answer.begin(), answer.end());
}
return answer;
}
내적
https://school.programmers.co.kr/learn/courses/30/lessons/70128
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <string>
#include <vector>
using namespace std;
int solution(vector<int> a, vector<int> b)
{
int answer(0);
for (int i = 0; i < a.size(); ++i)
answer += a[i] * b[i];
return answer;
}
가운데 글자 가져오기
https://school.programmers.co.kr/learn/courses/30/lessons/12903
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <string>
#include <vector>
using namespace std;
string solution(string s)
{
string answer = "";
int iSize(s.size()), iNum(iSize / 2);
if (iSize % 2) //홀수
{
answer = s[iNum];
}
else if (!(iSize % 2)) //짝수
{
answer = s[iNum - 1];
answer += s[iNum];
}
return answer;
}
직사각형 별찍기
https://school.programmers.co.kr/learn/courses/30/lessons/12969
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <iostream>
using namespace std;
int main(void)
{
int a;
int b;
cin >> a >> b;
for(int i = 0; i < b; ++i)
{
for(int j = 0; j < a; ++j)
{
cout << "*";
}
cout << endl;
}
return 0;
}
왜 이런 쉬운 문제가..?
'프로그래밍 > 코딩테스트' 카테고리의 다른 글
[프로그래머스] 1레벨 문제 (0) | 2023.06.21 |
---|---|
[프로그래머스] 1레벨 (0) | 2023.06.20 |
[프로그래머스] 1레벨 여러문제 (0) | 2023.06.11 |
[프로그래머스] 1레벨 문제 (0) | 2023.05.31 |
[프로그래머스] 1레벨 쉬운 문제 여러개 (0) | 2023.05.30 |
댓글