Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
7_002 completed
Browse files Browse the repository at this point in the history
  • Loading branch information
truonghoangkhiem committed Nov 2, 2023
1 parent 8355c86 commit 9cbe699
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion Problem_007/7_002.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@

#include <iostream>
using namespace std;
#define MAX 16

void Nhapmang(int a[][MAX], int &n);
void Xuatmang(int a[][MAX], int n);

int main()
{
int n, a[MAX][MAX];
Nhapmang(a,n);
Xuatmang(a,n);

return 0;
}
}

void Nhapmang(int a[][MAX], int& n)
{
cin >> n;
int fib[400];
int fibn = n * n;
fib[0] = 1;
fib[1] = 1;
for (int i = 2; i < fibn; i++)
fib[i] = fib[i - 1] + fib[i - 2];

for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
a[i][j] = fib[i + j];
}

void Xuatmang(int a[][MAX], int n)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
cout << a[i][j] << " ";
cout << endl;
}
}

0 comments on commit 9cbe699

Please sign in to comment.