새벽1시 넘어서 자바반에 놀러가보니
두명이 문제를 못풀어 낑낑대고있어서..
컨셉을 설명해주고 왔다.
심심해서 집에와서 설명해준대로 해본 코딩..
#include <stdio.h>
두명이 문제를 못풀어 낑낑대고있어서..
컨셉을 설명해주고 왔다.
심심해서 집에와서 설명해준대로 해본 코딩..
#include <stdio.h>
int main()
{
int inputA, inputB, inputC, temp; //변수선언
int La,Lb,Lc,Ltemp;
int constant=55; //기준값
printf("A값을입력하시오 : "); //값 할당받기
scanf("%d",&inputA);
printf("B값을입력하시오 : ");
scanf("%d",&inputB);
printf("C값을입력하시오 : ");
scanf("%d",&inputC);
La=constant-inputA; //거리측정
Lb=constant-inputB;
Lc=constant-inputC;
La=La*La; //절대거리산정
Lb=Lb*Lb;
Lc=Lc*Lc;
if (Lb>Lc) //크기비교후 자리바꾸기
{
Ltemp=Lb;
Lb=Lc;
Lc=Ltemp;
temp=inputB;
inputB=inputC;
inputC=temp;
}
if (La>Lb)
{
Ltemp=Lb;
Lb=La;
La=Ltemp;
temp=inputB;
inputB=inputA;
inputA=temp;
}
if (Lb>Lc)
{
Ltemp=Lb;
Lb=La;
La=Ltemp;
temp=inputB;
inputB=inputA;
inputA=temp;
}
printf("55에서 가까운 순서는 %d->%d->%d",inputA,inputB,inputC); //출력
return 0;
}