# 第五周 多層重複敘述 for 多個重複叙述彼此重疊的情形,便稱之爲多層的重複叙述(巢狀迴圈)在寫程式時經常被使用,用來簡化程式的流程,在這裡是指 while/for 裡面還有 while/for 的情況。 ## PRATICE : cout九九乘法表 ```cpp= #pragma warning(disable : 4996) #include <iostream> #include <string> using namespace std; int main() { string str = ""; char product[3]; for (int i = 1; i <= 9; i++) { for (int j = 1; j <= 9; j++) { sprintf(product, "%2d", i * j); str += to_string(i) + "*" + to_string(j) + "=" + product; if (j != 9) str += ", "; } cout << str << endl; str = ""; } system("pause"); } ```
×
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