the beginning

/This is the first code I wrote after learning c,and I learnt the first coding skill that is using array to solve problems. 😃/
/My prof was teaching us trash, so I just study on bilibili./
/This is a code for generating Fibonacci sequence till the i-th we want./

include <stdio.h>

int main(int argc, const char * argv[])
{

int i;
printf("Enter the number of terms in the Fibonacci sequence: ");
scanf("%d",&i);
int x, y[i];
printf("0\n1\n");
for (y[0]=0,y[1]=1,x=0;x<i-2;x++)
     {
    y[x+2]=y[x+1]+y[x];
    printf("%d\n",y[x+2]);
     }

return 0;

}

posted @ 2024-02-22 12:06  我要成为(c语言)高手  阅读(21)  评论(0)    收藏  举报