题解 | #农夫、羊、菜和狼的故事#

农夫、羊、菜和狼的故事

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;
}

全部评论

相关推荐

点赞 评论 收藏
分享
刘湘_passion:太强了牛肉哥有被激励到
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务