Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- using namespace std;
- const int n = 5;
- void printMat(int a[][n]) {
- for (int i = 0; i < n; i++) {
- cout << '(';
- for (int j = 0; j < n; j++) {
- if (j != n-1)
- cout << a[i][j] << '\t';
- else
- cout << a[i][j];
- }
- cout << ")\n";
- }
- }
- int main() {
- setlocale(LC_ALL, "Rus");
- cout << "Матрица " << n << 'x' << n << '\n';
- int mat[n][n];
- for (int i = 0; i < n; i++)
- mat[i][0] = mat[0][i] = 1;
- for (int i = 1; i < n; i++) {
- for (int j = 1; j < n; j++) {
- mat[i][j] = mat[i-1][j] + mat[i][j-1];
- }
- }
- printMat(mat);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement