hour06_2.cpp
来自「《24学时精通c++》的随书源码的下半部分。欢迎下载学习。」· C++ 代码 · 共 16 行
CPP
16 行
//Listing 6.13 //Illustrates nested for loops #include <iostream> int main() { int rows, columns;
int i; char theChar; std::cout << "How many rows? "; std::cin >> rows; std::cout << "How many columns? "; std::cin >> columns; std::cout << "What character? "; std::cin >> theChar;
i = 0;
while (i < rows) { for (int j = 0; j < columns; j++) std::cout << theChar;
// To replace the second for loop, comment the above 2 lines
// and uncomment the next 6
// j = 0;
// while (j < columns)
// {
// std::cout << theChar;
// j++;
// }
// Note that the for did not have a block {} but the while
// does because it has more than one statement (j++ is the second).
std::cout << "\n";
i++; } return 0; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?