Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

#include <iostream> #include <algorithm> const int maxrow = 10; const int maxcol = 10;…

  1. User

    #include #include

    const int max_row = 10; const int max_col = 10;

    using namespace std;

    //lesson 1 void sorting(int arr[max_row][max_col], int row, int col) { for (int i = 0; i < row; ++i) { sort(arr[i], arr[i] + col); } }

    void display_arr(int arr[max_row][max_col],int row, int col) { cout << "LESSON 1: Sorted Arr:\n"; for (int i = 0; i < row; ++i) { for (int j = 0; j < col; ++j) { cout << arr[i][j] << "\t"; } cout << endl; } }

    int sum_row(int arr[max_row][max_col], int row, int col) { int rowSum = 0;

    for (int j = 0; j < col; ++j)
    {
        rowSum += arr[row][j];
    }
    return rowSum;
    

    }

    int sum_col(int arr[max_row][max_col], int row, int col) { int colSum = 0; for (int i = 0; i < row; ++i) { colSum += arr[i][col]; } return colSum;

    }

    int total_sum(int arr[max_row][max_col], int row, int col) { int totalSum = 0; for (int i = 0; i < row; ++i) { for (int j = 0; j < col; ++j) { totalSum += arr[i][j]; } } return totalSum; }

    void display_table(int arr[max_row][max_col],int row, int col) { cout << "LESSON 2: CREATE TABLE:\n"; for (int i = 0; i < row; ++i) { for (int j = 0; j < col; ++j) { cout << arr[i][j] << "\t"; } cout << "|"<< "\t" <<sum_row(arr,i,col) << endl; }

    for(int i = 0; i< col+7; i++)
    {
        cout << "----";
    }
    cout << endl;
    
    for (int i = 0; i < col; i++)
    {
        cout << sum_col(arr,row,i) << "\t";    
    
    }
     
    cout << "|\t"<< total_sum(arr,row,col);
    

    }

    int main() { int row, col; cout << "Enter rows: "; cin >> row; cout << "Enter cols: "; cin >> col;

    int arr[max_row][max_col];
    
    cout << "Enter element:\n";
    for (int i = 0; i < row; ++i) {
        for (int j = 0; j < col; ++j) {
            cin >> arr[i][j];
        }
    }
    
    sorting(arr, row, col);
    
    display_arr(arr,row,col);
    
    display_table(arr,row,col);
            
    return 0;
    

    } проверь, есть ли в этом коде динамические двумерные массивы?

  2. Assistant

    Нет, в данном коде отсутствуют динамические двумерные массивы. Вместо этого используется статический двумерный массив arr размером max_row x max_col. Размер этого массива задается заранее и не может быть изменен во время выполнения программы.