김토리·2024년 2월 5일

알고리즘

목록 보기
6/27

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

int solution(int num1, int num2) {
    int answer = (num1 *1000/ num2 * 1000)/1000 ;
    return answer;
}

위 코드에서는 1000을 곱하고 1000을 다시 나누는 것이므로 생략할 수 있다.

따라서 중복된 부분을 삭제하면 아래 코드와 같다.

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

int solution(int num1, int num2) {
    int answer = (num1 *1000/ num2) ;
    return answer;
}
profile
웹 개발하며 데이터 분석, AI 공부하는 jinveloper

0개의 댓글