style: format code

This commit is contained in:
yanglbme
2019-08-21 10:10:08 +08:00
parent abc0d365de
commit 69ddc9fc52
101 changed files with 3154 additions and 2984 deletions

View File

@@ -1,24 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
int arr[1000000];
int fib(int n){
if(arr[n]==-1){
if(n<=1)
int fib(int n)
{
if (arr[n] == -1)
{
if (n <= 1)
arr[n] = n;
else
arr[n] = fib(n-1) + fib(n-2);
arr[n] = fib(n - 1) + fib(n - 2);
}
return arr[n];
}
int main(int argc, char const *argv[])
{
int n;
cout<<"Enter n: ";
cin>>n;
for (int i = 0; i < n+1; ++i)
cout << "Enter n: ";
cin >> n;
for (int i = 0; i < n + 1; ++i)
{
arr[i] = -1;
}
cout<<"Fibonacci number is "<<fib(n)<<endl;
cout << "Fibonacci number is " << fib(n) << endl;
return 0;
}