problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
luogu::P5732类 参考

洛谷 P5732 【深基5.习7】杨辉三角 更多...

#include <luogu.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

洛谷 P5732 【深基5.习7】杨辉三角

在文件 luogu.h462 行定义.

成员函数说明

◆ main()

int luogu::P5732::main ( istream &  cin,
ostream &  cout 
)
static

在文件 luogu.cpp1552 行定义.

1552 {
1553 int n;
1554 cin >> n;
1555 auto *triangle = new int *[n];
1556 for(int i = 0; i < n; i++) {
1557 triangle[i] = new int[i + 1];
1558 for(int j = 0; j <= i; j++) {
1559 if(j == 0 || j == i) {
1560 triangle[i][j] = 1;
1561 } else {
1562 triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j];
1563 }
1564 cout << triangle[i][j] << " ";
1565 }
1566 cout << endl;
1567 }
1568 for(int i = 0; i < n; i++) {
1569 delete[] triangle[i];
1570 }
1571 delete[] triangle;
1572 return 0;
1573 }

被这些函数引用 luogu::TEST().


该类的文档由以下文件生成: