OneCompiler

weather program

1618

#include <iostream>
#include <limits> // For std::numeric_limits

// Function to find the country code with the lowest temperature
int findLowestTemperatureCountryCode(int countryCodes[], float temperatures[], int size) {
int minCode = countryCodes[0];
float minTemp = temperatures[0];

for (int i = 1; i < size; ++i) {
    if (temperatures[i] < minTemp) {
        minTemp = temperatures[i];
        minCode = countryCodes[i];
    }
}

return minCode;

}

int main() {
int N;
std::cin >> N;

// Arrays to store country codes and temperatures
int countryCodes[N];
float temperatures[N];

// Read country codes and temperatures
for (int i = 0; i < N; ++i) {
    std::cin >> countryCodes[i] >> temperatures[i];
}

// Find and print the country code with the lowest temperature
int lowestTempCountryCode = findLowestTemperatureCountryCode(countryCodes, temperatures, N);
std::cout << lowestTempCountryCode << std::endl;

return 0;

}