-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodinggames-temperature.cpp
More file actions
40 lines (33 loc) · 959 Bytes
/
codinggames-temperature.cpp
File metadata and controls
40 lines (33 loc) · 959 Bytes
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
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
int main()
{
int n; // the number of temperatures to analyse
cin >> n; cin.ignore();
if(n==0){
cout << 0 << endl;
return 0;
}
int arr[1005];
int min = numeric_limits<int>::max();
for (int i = 0; i < n; i++) {
int t; // a temperature expressed as an integer ranging from -273 to 5526
cin >> t; cin.ignore();
// cout<<t<<endl;
arr[i] = t;
if (abs(arr[i]) < abs(min) or (abs(arr[i]) == abs(min) and arr[i]>min))
min = arr[i];
//cout<< min <<endl;
}
// Write an answer using cout. DON'T FORGET THE "<< endl"
// To debug: cerr << "Debug messages..." << endl;
cout << min << endl;
}