a/c cho em hỏi, em viết 1 chương trình như thế này nhưng không hiểu sao chạy trên Dev C mãi không được mà chạy trên Cfree thì lại được.
#include<iostream>
#include<fstream>
using namespace std;
class matran;
class vector{
private:
int *a;
int n;
public:
friend vector operator*(matran,vector);
void nhapbp(){
cout<<"nhap so phan tu cua vector: "; cin>>n;
a=new int[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
}
void xemmh(){
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
}
};
class matran{
private:
int **b; int n; int m;
public:
friend matran operator-(matran);
friend vector operator*(matran,vector);
void nhapbp(){
cout<<"nhap so hang so cot: "; cin>>m>>n;
b=new int*[m];
for(int i=0;i<m;i++){
b[i]=new int[n];
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>b[i][j];
}
}
}
};
vector operator*(matran a, vector v){
vector c;
if(a.m==v.n&&a.m==a.n){
c.n=v.n;
for(int i=0;i<a.n;i++){
c.a[i]=0;
for(int j=0; j<a.n;j++){
c.a[i]+=v.a[j]*a.b[i][j];
}
}
}
return c;
}
main(){
vector v; matran m;
v.nhapbp();
m.nhapbp();
vector s;
s=m*v; s.xemmh();
}




83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?