코드
using namespace std;
long long solution(int a, int b) {
long long answer = 0;
if(a>b){
for(int i=b;i<=a;i++){
answer=answer+i;
}
}else if(a<b){
for(int i=a;i<=b;i++){
answer=answer+i;
}
}else{
answer=a;
}
return answer;
}
'C++ > programmers 코딩테스트(level 1) C++' 카테고리의 다른 글
[C/C++] programmers Level 1 약수의 합 (0) | 2023.09.18 |
---|---|
[C/C++] programmers Level 1 완주하지 못한 선수 (0) | 2023.09.14 |
[C/C++] programmers Level 1 수박수박수박수박수박수? (0) | 2023.09.12 |
[C/C++] programmers Level 1 나머지가 1이 되는 수 찾기 (0) | 2023.09.04 |
[C/C++] programmers Level 1 콜라 문제 (0) | 2023.09.02 |