* C, Python, Java 등등 다양한 언어를 지원하며 COMPETE라는 경쟁 문제도 존재
* 난이도는 쉬움(easy) 부터 다양하며, if문 for문을 땐 초보자라도 문제 풀이가 가능
submit 버튼을 누르면 클리어한 게임을 볼 수 없기 때문에, 이번 게시글만 .. 말로 설명하고 다음부터는 캡쳐해서 올리겠슴당..
문제에서 원하는 답은 " 게임에서 주어진 온도에서 0에 가장 가까운 값을 출력해줘 (대신 5, -5 같은 값이 있으면 양수인 5를 출력해)" 라는것.
문제에 접근하면 풀어야하는 다양한 조건의 퀘스트 들이 있다.
한번의 소스 실행으로 전부 퀘스트를 클리어 해야하는 '제한조건' 같은 것이다.
그 제한조건을 요약해보면
' 음수 양수를 판별해 비교하고, 온도가 0 일때 0을 출력하는것. '
내 풀이를 요약해보면 0을 기준으로 거리값을 계산해 (어차피 거리값은 온도 값의 절댓값이다.) 가장 적은 거리의 index를 온도가 저장된 배열의 index와 같게해 가장 0에 가까운 온도를 출력해주었다. 대신 0 일때는 예외적으로 if를 써서 0일때 0일 출력하게 해야한다.)
Temperatures 소스.
import java.util.*;
import java.io.*;
import java.math.*;
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
class Solution {
public static void main(String args[]) {
// 1. definition variable.
Scanner in = new Scanner(System.in);
String array[] ;
int min_n = 5526;
int save_i = 0;
// 2. input value.
int n = in.nextInt(); // the number of temperatures to analyse
if (in.hasNextLine()) {
in.nextLine();
}
int distance[] = new int[n];
String temps = in.nextLine(); // the n temperatures expressed as integers ranging from -273 to 5526
array = temps.split(" ");
int int_array[] = new int[array.length];
// 3. Start algorithm.
System.err.println("[error] temps : " + temps + "\n[error] n : " + n );