In ma trận dùng class:
code :
#include <conio.h>
#include <iostream.h>
#include <math.h>
float b[100][100];
class MT
{
private:
int n,m;
public:
void nhap();
void xuat();
};
void MT::nhap()
{
int i,j;
cout<<"nhap so dong cua ma tran: ";
cin>>n;
cout<<"nhap so cot cua ma tran : ";
cin>>m;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout<<"b["<<i<<","<<j<<"]=";
cin>>b[i][j];
}
}
}
void MT::xuat()
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout<<b[i][j]<<" ";
}
cout<<"\n";
}
}
void main()
{
MT a;
a.nhap();
a.xuat();
getch();
}
0 Response to "In ma trận dùng class:"
Đăng nhận xét