这题目很简单,问题是细节处理处理很重要,在蓝桥杯省赛中你只要搞对一两道题目就有省三了。
实施代码
#include<stdio.h>
#include<math.h>
int main()
{ int n;
int t=0;
int b[9999];
scanf("%d",&n);
int i,j,k;
int a[100][100];
for(i=1;i<=99;i++)
for(j=1;j<=i;j++)
{ t++;
if(i==1)a[i][j]=1;
else if(j==i)a[i][j]=1;
else a[i][j]=a[i-1][j-1]+a[i-1][j];
b[t]=a[i][j];
}
t=0;
for(t=1;t<=999;t++)
if(b[t]==n)
goto here;
here:printf("%d",t);
return 0;
}
实施效果
怎么样是不是很简?关注本博主,更多精彩等你。。。。