题解 | #农夫、羊、菜和狼的故事#
农夫、羊、菜和狼的故事
https://www.nowcoder.com/practice/ab5702134dc5402b8c5156277c67cab1
#include "bits/stdc++.h" using namespace std; int main() { /* * 有一个农夫带一只羊、一筐菜和一只狼过河。如果没有农夫看管,则狼要吃羊,羊要吃菜。但是船很小,只够农夫带一样东西过河。问农夫该如何解此难题? */ cout << "sheep_go" << endl; cout << "nothing_come" << endl; cout << "wolf_go" << endl; cout << "sheep_come" << endl; cout << "vegetable_go" << endl; cout << "nothing_come" << endl; cout << "sheep_go" << endl; cout << "succeed" << endl; }