#include <iostream>

using namespace std;

const int Nmax = 10;

void Saisie(int tab[][Nmax], int &n1, int &n2, int &S, float &Moy);
void Affichage(int tab[][Nmax], int n1, int n2, int S, float Moy);

void main()
{
    int N1, N2, S;
    float Moy;
    int Tab[Nmax][Nmax];
    // i*n1 + j
    Saisie(Tab, N1, N2, S, Moy);
    Affichage(Tab, N1, N2, S, Moy);
}

void Saisie(int tab[][Nmax], int &n1, int &n2, int &S, float &Moy)
{
    cout << "Entrez le nombre de lignes : ";
    cin >> n1;
    cout << "Entrez le nombre de colonnes : ";
    cin >> n2;

    if (n1 > Nmax)
    {
        n1 = Nmax;
        cout << "La taille maximale du tableau est de " << Nmax;
    }
    if (n2 > Nmax)
    {
        n2 = Nmax;
        cout << "La taille maximale du tableau est de " << Nmax;
    }

    for (int i = 0; i < n1; i++)
    {
        for (int j = 0; j < n2; j++)
        {
            cout << "tab[" << i << "]" << "[" << j << "]" << " = ";
            cin >> tab[i][j];
            S += tab[i][j];
        }
    }

    Moy = (float)S / (n1 + n2);
}

void Affichage(int tab[][Nmax], int n1, int n2, int S, float Moy)
{
    for (int i = 0; i < n1; i++)
    {
        for (int j = 0; j < n2; j++)
        {
            cout << tab[i][j] << " ";
        }
        cout << endl;
        //        cout << "tab[" << i << "]" << " = " << tab[i] << endl;
    }

    cout << "Somme = " << S << endl;
    cout << "Moyenne = " << Moy << endl;
}