Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私が持っている場合:
const string food[] = {"Burgers", "3", "Fries", "Milkshake"} string word; cin >> word;
どうすれば単語と正しい食べ物を比較できますか? むしろ、ユーザーが「フライドポテト」と入力した場合、それを文字列配列と比較するにはどうすればよいですか?
とfind:
find
#include <algorithm> #include <iterator> auto it = std::find(std::begin(food), std::end(food), word); if (it != std::end(food)) { // found *it } else { // not found }