Skip to content

Commit

Permalink
递推法求解无符号第一类斯特林数(圆排列)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-XYS committed Dec 11, 2016
1 parent 20bf756 commit 897ab51
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Stirling-Number(Cycle,Unsigned,Recursion).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <cstdio>

using namespace std;

int n, su[100][100];

void init_su()
{
for (int i = 1; i <= n; i++)
{
su[i][0] = 0;
su[0][i] = 0;
}
su[0][0] = 1;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
su[i][j] = su[i - 1][j - 1] + su[i - 1][j] * (i - 1);
}
}
}

int main()
{
scanf("%d", &n);
init_su();
for (int i = 0; i <= n; i++)
{
for (int j = 0; j <= i; j++)
{
printf("%5d ", su[i][j]);
}
printf("\n");
}
return 0;
}

0 comments on commit 897ab51

Please sign in to comment.