728x90
반응형
정수 num1과 num2가 매개변수로 주어집니다. 두 수가 같으면 1 다르면 -1을 retrun하도록 solution 함수를 완성해주세요.
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int solution(int num1, int num2) {
int answer = 0;
if(num1 == num2){
answer = 1;
}
else answer = -1;
return answer;
}
if문 사용해서 경우1, -1이 각각 출력될 수 있도록 해주었다
728x90
반응형
'프로그래머스 C++ > Level.0' 카테고리의 다른 글
프로그래머스 C++ Level. 0 두 수의 나눗셈 (0) | 2023.02.28 |
---|---|
프로그래머스 C++ Level. 0 나이 출력 (0) | 2023.02.27 |
프로그래머스 C++ Level. 0 두 수의 차 (0) | 2023.02.27 |
프로그래머스 C++ Level. 0 나머지 구하기 (0) | 2023.02.27 |
프로그래머스 C++ Level. 0 몫 구하기 (0) | 2023.02.27 |