#include <iostream>
using namespace std;
void Nhap(int **,int,int);
double TrungBinhCotK(int**,int,int,int);
void Xuat(int **a,int m, int n,bool Odd = false)
{
for (int i = 0; i < m; ++i)
{
for (int j = 0; j < n; ++j)
{
if(Odd)
{
if(a[i][j] % 2 != 0) cout<<a[i][j]<<"\t";
else cout<<"x"<<"\t";
}
else cout<<a[i][j]<<"\t";
}
cout << endl;
}
}
int main()
{
int n, m;
cout << "m = "; cin >> m;
cout << "n = "; cin >> n;
int** a = new int* [m];
for (int i = 0; i < m; ++i)
{
a[i] = new int[n];
}
Nhap(a,m,n);
cout<<"Cau 3: \n";Xuat(a,m,n);
cout<<"Cau 4: \n";Xuat(a,m,n,true);
int k;
do
{
cout<<"(0 < k <= "<<n<<") k = ";
cin>>k;
}while(k <= 0 || k > n);
cout<<TrungBinhCotK(a,m,n,--k);
}
void Nhap(int **a,int m,int n)
{
for (int i = 0; i < m; ++i)
{
for (int j = 0; j < n; ++j)
{
cout<<"a["<<i<<"]["<<j<<"] = ";
cin>>a[i][j];
}
}
}
double TrungBinhCotK(int **a,int m,int n,int k)
{
double result = 0;
for(int i = 0; i < m;++i)
{
result += a[i][k];
}
return result/m;
}