📄 hour06_2.cpp
字号:
//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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -