2_29.cpp
来自「C++案例教程源代码」· C++ 代码 · 共 15 行
CPP
15 行
#include <iostream>
using namespace std;
int main()
{ long limits;
cout << "Enter a positive integer: "; cin >> limits;
cout << "Factorial numbers of "<<0<<" is " << 1<<endl;
cout << "Factorial numbers of "<<1<<" is " << 1<<endl;
long fac=1;
for(int i=2;fac<=limits;i++) //使用for 循环代替do-while循环
{ fac *= i;
cout << "Factorial numbers of "<<i<<" is " << fac<<endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?