C++ 杨辉三角,没有使用数组
C++ 杨辉三角,没有使用数组
C++ 杨辉三角,没有使用数组
- #include <iostream>
- #include <iomanip>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- int m, n, c = 1;
- cout << "\n";
- for (m = 1; m <=13; m++) {
- cout<<setw(40-3*m)<<c;
- for (n = 1; n<=m; n++) {
- c = c*(m-n+1)/n;
- cout<<setw(6)<<c;
- }
- cout << "\n";
- }
- system("pause");
- return 0;
- }
评论暂时关闭