ex3_13.cpp
来自「Visual C++ 2005的源代码」· C++ 代码 · 共 33 行
CPP
33 行
// Ex3_13.cpp
// Demonstrating nested loops to compute factorials
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
char indicator = 'n';
long value = 0,
factorial = 0;
do
{
cout << endl
<< "Enter an integer value: ";
cin >> value;
factorial = 1;
for(int i = 2; i <= value; i++)
factorial *= i;
cout << "Factorial " << value << " is " << factorial;
cout << endl
<< "Do you want to enter another value (y or n)? ";
cin >> indicator;
} while((indicator == 'y') || (indicator == 'Y'));
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?