본문 바로가기
728x90
반응형

C++9

c++(cpp) 프로그래머스 : 코딩테스트 - 완주하지 못한 선수 #include #include #include using namespace std; string solution(vector participant, vector completion) { string answer = ""; sort(participant.begin(), participant.end()); sort(completion.begin(), completion.end()); for(int i = 0; i < participant.size();i++) { if(participant[i] != completion[i]) { answer = participant[i]; return answer; } } return participant[participant.size()-1]; } 2023. 1. 23.
c++(cpp) 프로그래머스 - 코딩테스트 : k번째 수 #include #include #include using namespace std; vector solution(vector array, vector commands) { vector answer; for(int i = 0 ; i < commands.size() ; i++) { vector temp; for(int j = commands[i][0]-1 ; j < commands[i][1]; j ++) { temp.push_back(array[j]); } sort(temp.begin(), temp.end()); answer.push_back(temp[commands[i][2]-1]); } return answer; } 2023. 1. 23.
c++(cpp) 프로그래머스 - 코딩 테스트 : 약수의 합 #include #include using namespace std; int solution(int n) { int answer = 0; for(int i = 1 ; i 2022. 8. 11.
c++(cpp) 프로그래머스 - 코딩 테스트 : 부족한 금액 계산하기 using namespace std; long long solution(int price, int money, int count) { long long answer = 0; long long total_price=0; for(int i = 1 ; i = 0) return 0; return answer * -1; } 2022. 7. 31.
c++(cpp) 프로그래머스 - 코딩 테스트 : 나머지가 1이 되는 수 찾기 #include #include using namespace std; int solution(int n) { int answer = 0; for(int i = 2 ; i < n;) { if(n%i == 1) { answer = i; break; } i++; } return answer; } 2022. 7. 31.
c++(cpp)_random matrix(10X10) #include #include #include using namespace std; int main() { ofstream fout("output.txt"); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { int output = rand() % 101; fout 2022. 7. 28.
c++(cpp)_Unit matrix(10*10) 만들기 #include #include using namespace std; int main() { int colum = 1, row = 1; while(colum < 11) { while(row < 11) { int num; if(colum == row) { num = 1; } else { num = 0; } cout 2022. 7. 28.
c++(cpp)_성적 산출 #include using namespace std; int main() { char grade = 'X'; int score; cout > score; if (score = 0) { if (score >= 90) { grade = 'A'; cout 2022. 7. 28.
c++(cpp) 프로그래머스 : 코딩 테스트 - 정수 제곱근 판별 #include #include #include using namespace std; long long solution(long long n) { long long answer = 0; int num = sqrt(n); if( pow(num, 2) == n) { answer = pow(num+1,2); } else if(n == 1) { answer = 4; } else { answer = -1; } return answer; } 2022. 7. 27.
728x90
반응형