Created
February 5, 2026 23:46
-
-
Save nicolekorch/58766455a1e252cb30f776d242958a03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Мережа