Quantcast
Channel: Dạy Nhau Học - Latest topics
Viewing all articles
Browse latest Browse all 34350

Giúp giải thích đoạn code tính số Fibonacci

$
0
0

@honghm wrote:

tại sao lại cần dòng em comment lại vậy ạ
comment lại thì chạy bị lỗi còn bỏ comment chạy bthg ạ, em cảm ơn

#include <stdio.h>

long fibo[100];

long fibonacci(int n) {
if(n==1 || n==2) return 1;
	// if (fibo[n]) return fibo[n];
fibo[n]=fibonacci(n-1) + fibonacci(n-2);
return fibo[n];
}

int main() {
	int n, k;
fibo[1] = 1;
fibo[2] = 1;
fibonacci(92);
scanf("%d", &k);
while (k--) {
    scanf("%d", &n);
    printf("%ld\n", fibo[n]);
}
return 0;

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 34350

Trending Articles