From 7586d211ac816b9327806a53f9434a8aead636cd Mon Sep 17 00:00:00 2001 From: prz83jtxm <2747847580@qq.com> Date: Wed, 5 Mar 2025 20:23:21 +0800 Subject: [PATCH 1/4] ADD file via upload --- 课设2.cpp | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 课设2.cpp diff --git a/课设2.cpp b/课设2.cpp new file mode 100644 index 0000000..cda0e9d --- /dev/null +++ b/课设2.cpp @@ -0,0 +1,89 @@ +#include +#include +#include +#include +#include + +using namespace std; + +struct WeatherData +{ + string cityName; + int temperature; + int humidity; + int windSpeed; +}; +bool readWeatherData(const string& filename, vector& data) +{ + ifstream File; + File.open(filename); + + + if(File.is_open()) + { + string line; + char ws; + while (getline(File, line)) + { + istringstream iss(line); + WeatherData weather; + + if (getline(iss, weather.cityName, ',') && + (iss >> weather.temperature >> ws >> weather.humidity >> ws >> weather.windSpeed)) + { + data.push_back(weather); + } + } + + } + else + { + cout << "޷ļ " << filename << endl; + return false; + } + File.close(); + return true; +} + +void findAndDisplayWeather(const string& cityName, const vector& data) +{ + bool found = false; + for (const auto& weather : data) + { + if (weather.cityName == cityName) + { + found = true; + cout << cityName << "Ϊ¶" << weather.temperature + << ", ʪ" << weather.humidity + << ", " << weather.windSpeed << endl; + return; + } + } + + if (!found) + { + cout << "δҵ " << cityName << " ݡ" << endl; + } +} + +int main() +{ + string filename; + cout << "ļ"; + cin >> filename; + + string cityName; + cout << "Ҫij"; + cin >> cityName; + + vector weatherData; + if (!readWeatherData(filename, weatherData)) + { + return 1; + } + + findAndDisplayWeather(cityName, weatherData); + + return 0; +} + From 8454512b2f193ce33025120d99004e9b2d909e53 Mon Sep 17 00:00:00 2001 From: Lappland333 <150466250+Lappland333@users.noreply.github.com> Date: Thu, 27 Mar 2025 14:58:16 +0800 Subject: [PATCH 2/4] =?UTF-8?q?Delete=20=E8=AF=BE=E8=AE=BE2.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 课设2.cpp | 89 ----------------------------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 课设2.cpp diff --git a/课设2.cpp b/课设2.cpp deleted file mode 100644 index cda0e9d..0000000 --- a/课设2.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include -#include -#include -#include -#include - -using namespace std; - -struct WeatherData -{ - string cityName; - int temperature; - int humidity; - int windSpeed; -}; -bool readWeatherData(const string& filename, vector& data) -{ - ifstream File; - File.open(filename); - - - if(File.is_open()) - { - string line; - char ws; - while (getline(File, line)) - { - istringstream iss(line); - WeatherData weather; - - if (getline(iss, weather.cityName, ',') && - (iss >> weather.temperature >> ws >> weather.humidity >> ws >> weather.windSpeed)) - { - data.push_back(weather); - } - } - - } - else - { - cout << "޷ļ " << filename << endl; - return false; - } - File.close(); - return true; -} - -void findAndDisplayWeather(const string& cityName, const vector& data) -{ - bool found = false; - for (const auto& weather : data) - { - if (weather.cityName == cityName) - { - found = true; - cout << cityName << "Ϊ¶" << weather.temperature - << ", ʪ" << weather.humidity - << ", " << weather.windSpeed << endl; - return; - } - } - - if (!found) - { - cout << "δҵ " << cityName << " ݡ" << endl; - } -} - -int main() -{ - string filename; - cout << "ļ"; - cin >> filename; - - string cityName; - cout << "Ҫij"; - cin >> cityName; - - vector weatherData; - if (!readWeatherData(filename, weatherData)) - { - return 1; - } - - findAndDisplayWeather(cityName, weatherData); - - return 0; -} - From febf796b791def4462f5cb78b1525b7c797f33e9 Mon Sep 17 00:00:00 2001 From: prz83jtxm <2747847580@qq.com> Date: Thu, 27 Mar 2025 14:59:45 +0800 Subject: [PATCH 3/4] 111 --- TEST11.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 TEST11.txt diff --git a/TEST11.txt b/TEST11.txt new file mode 100644 index 0000000..c1b8d63 --- /dev/null +++ b/TEST11.txt @@ -0,0 +1,3 @@ +111 +222 +333 \ No newline at end of file From f22ef845b22bc43bfbc07a4e7d34c2e2bf806512 Mon Sep 17 00:00:00 2001 From: prz83jtxm <2747847580@qq.com> Date: Thu, 27 Mar 2025 15:01:48 +0800 Subject: [PATCH 4/4] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 142f0a6..d1b26fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # 小米便签 ## 你好 -##俺好 1.维护至Android11(当前手机版本) 2.java语言,基于安卓开发 3.查找网上相关文档