oldmac2.cpp

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

CPP
50
字号
#include <iostream>#include <string>using namespace std;// working version of old macdonald, functions with more than one parametervoid 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 Verse(string animal, string noise){    Refrain();    HadA(animal);    WithA(noise);    Refrain();}int main(){    Verse("pig","oink");    cout << endl;    Verse("cow","moo");    return 0;}

⌨️ 快捷键说明

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