#include <string> #include <vector> using namespace std; long long solution(int a, int b) { long long answer = 0; long long sum = 0; if(a > b) { int temp = a; a = b; b = temp; } for(int i = a; i <= b; i++) { sum += i; } answer = sum; return answer; } | cs |
'Programmers > Level 1' 카테고리의 다른 글
[프로그래머스 1] 문자열 내 p와 y의 개수 (C/C++) (0) | 2019.10.17 |
---|---|
[프로그래머스 1] 문자열 내 마음대로 정렬하기 (C/C++) (0) | 2019.10.17 |
[프로그래머스 1] 나누어 떨어지는 숫자 배열 (C/C++) (0) | 2019.10.17 |
[프로그래머스 1] 같은 숫자는 싫어 (C/C++) (0) | 2019.10.17 |
[프로그래머스 1] 가운데 글자 가져오기 (C/C++) (0) | 2019.10.17 |