Skip to content

Instantly share code, notes, and snippets.

@nicolekorch
Created February 5, 2026 23:46
Show Gist options
  • Select an option

  • Save nicolekorch/58766455a1e252cb30f776d242958a03 to your computer and use it in GitHub Desktop.

Select an option

Save nicolekorch/58766455a1e252cb30f776d242958a03 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;
// Функція для отримання погоди
void showWeather(const string& city) {
string command = "curl -s \"wttr.in/" + city + "?format=3\"";
system(command.c_str());
}
int main() {
// Список улюблених міст
vector<string> favoriteCities = {
"Kyiv",
"Lviv",
"Odesa",
"London",
"Paris",
"Berlin",
"Tokyo",
"NewYork",
"Rome",
"Barcelona"
};
cout << "Weather in favorite cities:\n";
for (const string& city : favoriteCities) {
showWeather(city);
}
cout << "\nEnter city name in English: ";
string userCity;
cin >> userCity;
cout << "Weather in " << userCity << ":\n";
showWeather(userCity);
return 0;
}
void showWeather(const string& city) {
string command = "curl -s \"wttr.in/" + city +
"?format=Temperature:%20%t%20Wind:%20%w%20Humidity:%20%h%20Pressure:%20%P%20Precip:%20%p\"";
system(command.c_str());
cout << endl;
}
g++ weather.cpp -o weather
./weather
g++ weather.cpp -o weather.exe
weather.exe
@nicolekorch
Copy link
Author

Мережа

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment