C언어 Express 5장 #03

SEUNGJUN JEONG·2022년 4월 17일
0

C/C++

목록 보기
3/15

문제

3개의 정수값 중에서 최대값 출력

답안

#include <stdio.h>

int main() {
    int a, b, c, max;
    printf("3개의 정수를 입력하시오: ");
    scanf("%d %d %d", &a, &b, &c);

    max = (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);

    printf("최대값: %d", max);

    return 0;
}

삼항연산을 이렇게 복합적으로 작성할 수도 있다!

profile
Microsoft Learn Student Ambassadors

0개의 댓글