Advertisement
KeRya

Temperatures

Feb 23rd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7.  
  8. /**
  9.  * Auto-generated code below aims at helping you parse
  10.  * the standard input according to the problem statement.
  11.  **/
  12. class Solution
  13. {
  14.     static void Main(string[] args)
  15.     {
  16.         int n = int.Parse(Console.ReadLine()); // the number of temperatures to analyse
  17.         string[] inputs = Console.ReadLine().Split(' ');
  18.         int min = 5527;
  19.         for (int i = 0; i < n; i++)
  20.         {  
  21.            
  22.              int t = int.Parse(inputs[i]);// a temperature expressed as an integer ranging from -273 to 5526
  23.                Console.Error.WriteLine(inputs[i]);
  24.              if (Math.Abs(t)< Math.Abs (min))
  25.              min = t;
  26.              if ((Math.Abs(t)==Math.Abs (min)) && (t>min))
  27.              min = Math.Abs(t);
  28.              Console.Error.WriteLine(min);
  29.              
  30.             }
  31.                 if (min == 5527)
  32.                  min=0;
  33.         // Write an action using Console.WriteLine()
  34.         // To debug: Console.Error.WriteLine("Debug messages...");
  35.         Console.WriteLine(min);
  36.        
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement