CSLT FIBOLACY
#include<stdio.h>
#include<conio.h>
/*long fibo(int k)
{
if(k==1||k==2) return 1;
return fibo(k-2)+fibo(k-1);
} */
main()
{
clrscr();
long a[100];
int k,n,dem=0,i;
unsigned int x;
printf("k=");scanf("%d",&k);
printf("
can hien thi bao nhieu so:");scanf("%d",&n);
printf("
nhap x=");scanf("%u",&x);
printf("
%d so ke tiep lon hon %d trong day la: ",n,x);
dem=0;
a[1]=a[2]=1;
for(i=3;i<=k;i++)
a[i]=a[i-1]+a[i-2];
for(i=1;i<=k;i++)
{
if(a[i]>x)
{
printf("\t%ld",a[i]);
dem++;
if(dem>=n) break;
}
}
/*while((i<=k)&& (dem<=n))
{
if(fibo(i)>x)
{ printf("\t%ld",fibo(i));
dem++;
if(dem >=n) break;
else i++;
}
}*/
getch();
}
Bạn đang đọc truyện trên: AzTruyen.Top