结合杨辉三角的题目,做出来很有成就,哈哈哈,我是小菜b,
<pre name="code" class="cpp">#include<stdio.h>
#define M 22
int main()
{
int a[M][M],i,j;
int n;
int t,te=0;
int s[M]={0};
for(i=0;i<M;i++)
{
for(j=0;j<=i;j++)
{
if(i==j||j==0)
a[i][j]=1;
else
a[i][j]=a[i-1][j]+a[i-1][j-1];
s[i]+=j*a[i][j];
s[i]+=a[i][j];
}
}
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("%d\n",s[n-1]);
}
return 0;
}