Notice
Recent Posts
Recent Comments
Link
«   2025/09   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

이것저것

C언어 swea 1284 수도 요즘 전쟁 본문

Language/C언어

C언어 swea 1284 수도 요즘 전쟁

olivia-com 2020. 11. 19. 22:10

https://swexpertacademy.com/main/identity/anonymous/loginPage.do

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

#include <stdio.h>

int A(p,w){ //A사 계산  A사 : 1리터당 P원의 돈 지불  
	int result;
	result = p * w;
	return result;
}

int B(q,r,s,w){ //B사 계산  
	int result;
	if(w <= r){ 
// 월간 사용량이 R리터 이하인 경우 요금은 기본 요금만 청구
		result = q;
	}
	else{
// R 리터보다 많은 양을 사용한 경우 초과량에 대해 1리터당 S원의 요금 지불 
		result = q + s * (w-r);
	}
	return result;
}

int main(void){
	int test_case, i; //케이스 수  
	int P,Q,R,S,W;
	int result;
	/* P: A사 1리터당 내는 돈
	Q: B사 기본 요금
	R: B사 기준 월간 사용량
	S: B사 1리터당 내는 돈
	W: 종민의 집에서 한 달간 사용하는 수도의 양*/ 
	int a, b;
	scanf("%d", &test_case);
	for(i = 0; i < test_case; i++){
		scanf("%d %d %d %d %d", &P, &Q, &R, &S, &W);
		a = A(P,W); // A사 비용  
		b = B(Q,R,S,W); // B사 비용 
		result = a<b ? a : b;
	printf("#%d %d", i + 1, result);	
	}
	
	return 0;
	
}

'Language > C언어' 카테고리의 다른 글

C언어 swea 1966 숫자를 정렬하자  (0) 2020.11.19
C언어 swea 1976 시각 덧셈  (0) 2020.11.19
C언어 swea 1926 간단한 369게임  (0) 2020.11.19
이진 체계 정리  (0) 2020.11.19
C언어 swea 1986 지그재그 숫자  (0) 2020.11.19