oldmac1.cpp

来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C++ 代码 · 共 58 行

CPP
58
字号
#include <iostream>#include <string>using namespace std;// working version of old macdonald, single parameter proceduresvoid EiEio(){    cout << "Ee-igh, Ee-igh, oh!" << endl;}void Refrain(){    cout << "Old MacDonald had a farm, ";    EiEio();}void HadA(string animal){    cout << "And on his farm he had a " << animal << ", ";    EiEio();}void WithA(string noise)// the principal part of a verse{    cout << "With a " << noise << " " << noise << " here" << endl;    cout << "And a " << noise << " " << noise << " there" << endl;    cout << "Here a " << noise << ", "          << "there a " << noise << ", "         << " everywhere a " << noise << " " << noise << endl;}void Pig(){    Refrain();    HadA("pig");    WithA("oink");    Refrain();}void Cow(){    Refrain();    HadA("cow");    WithA("moo");    Refrain();}int main(){    Cow();    cout << endl;    Pig();    return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?