PS
SWEA [D3] - 18662. 등차수열 만들기 (C언어)
kugnuoy
2023. 11. 8. 14:45
[18662]
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[코드]
#include <stdio.h>
float find_min(float x, float y, float z) {
if (x < 0) x = -x;
if (y < 0) y = -y;
if (z < 0) z = -z;
if (x <= y && x <= z) return x;
else if (y <= x && y <= z) return y;
else return z;
}
int main() {
int T;
scanf("%d", &T);
for (int t = 0; t < T; t++) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
float min;
min = find_min((float)2 * b - a - c, (float)0.5*c - b + 0.5*a, (float)2 * b - a - c);
printf("#%d %.1f\n", t + 1, min);
}
}