Information Security Study

[백준] 2480: 주사위 세개 본문

Programming/C

[백준] 2480: 주사위 세개

gayeon_ 2024. 1. 7. 19:26

3개 주사위의 눈에 따라 상금을 계산하는 문제이다.

if 문으로 계산하면 된다.

 

 

 

입출력 예시이다.

 

 

 

#include <stdio.h>

int main() {
	
    int a;
    int b;
    int c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a == b && b == c) {
    	printf("%d", a * 1000 + 10000);
    } else if(a == b && a != c) {
    	printf("%d", a * 100 + 1000);
    } else if(b == c && b != a) {
    	printf("%d", b * 100 + 1000);
    } else if(a == c && a != b) {
    	printf("%d", a * 100 + 1000);
    } else if(a > b && a > c) {
    	printf("%d", a * 100);
    } else if(b > c && b > a) {
    	printf("%d", b * 100);
    } else {
    	printf("%d", c * 100);
    }
    return 0;
    
}

각 경우에 맞도록 else if문을 작성했다.

'Programming > C' 카테고리의 다른 글

[백준] 10950: A+B-3  (1) 2024.01.08
[백준] 2739: 구구단  (0) 2024.01.07
[백준] 2525: 오븐 시계  (0) 2024.01.07
[백준] 2884: 알람 시계  (0) 2024.01.07
[백준] 9498: 시험 성적  (0) 2024.01.07