# 第十六周 自訂函式:基本型 * 可以使用別人寫好函式(函式庫) * 宣告函式在 ``` using namespace std; ```之下、```int main() ``` 之上 * 函式一旦執行到```return```就會立刻回傳,略過之後所有程式碼 練習: ```=cpp #include<iostream> using namespace std; void bird() { cout << " .-." << endl; cout << " /'v'\\" << endl; cout << " (/ \\)" << endl; cout << "='=\"=\"===< " << endl; cout << "mrf|_|" << endl; } void cat() { cout << " /\\_/\\" << endl; cout << " ____/ o o \\" << endl; cout << " /~____ =o= /" << endl; cout << " (______)__m_m)" << endl; } int main() { bird(); cout << "麻雀:早安~" << endl; cat(); cout << "貓:我要吃掉你!" << endl; bird(); cout << "麻雀:不要><" << endl; return 0; ``` ## output: ``` .-. /'v'\ (/ \) ='="="===< mrf|_| 麻雀:早安~ /\_/\ ____/ o o \ /~____ =o= / (______)__m_m) 貓:我要吃掉你! .-. /'v'\ (/ \) ='="="===< mrf|_| 麻雀:不要>< ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up