غربال
Member
- تاريخ التسجيل
- 17 أكتوبر 2011
- المشاركات
- 8
- المجموعة
- ذكر
- الدفعة الدراسية
- 2010
- الكلية
- كلية تقنية المعلومات
السلام عليكم شعب
تفضلو هذا الاسايمنت 9 من الاب
وسامحوني على الاختصارات و الاغلاط
اي احد يشوف غلط يخبرنا
عدلوه قبل رفعه للبلاك بورد عاد
لانه ناقص cout
ادعو لينا
تفضلو هذا الاسايمنت 9 من الاب
وسامحوني على الاختصارات و الاغلاط
اي احد يشوف غلط يخبرنا
عدلوه قبل رفعه للبلاك بورد عاد لانه ناقص cout
PHP:
#include<iostream>
using namespace std;
class Table {
private:
int NRS;
int NCS;
double **Mat;
public:
Table(int=10,int=10);
Table(const Table& m);
void inputTable();
void printTable();
void swapRows(int,int);
~Table();
};
Table::Table(int a, int b){
NRS=a;
NCS=b;
Mat = new double *[NRS];
for(int i=0;i<NRS;++i)
{
Mat[i] = new double[NCS];
for(int j=0;j<NCS;j++){
Mat[i][j] = 0;
}
}
}
Table::~Table(){
for(int i=0;i<NCS;i++)
delete [] Mat[i];
delete [] Mat;
}
Table::Table(const Table &m)
{
NCS=m.NCS;
NRS=m.NRS;
Mat = new double *[NRS];
for(int i=0;i<NRS;++i)
{
Mat[i] = new double[NCS];
for(int b=0;b<NCS;b++){
Mat[i][b] = m.Mat[i][b];
}
}
}
void Table::printTable(){
for(int i=0;i<NRS;i++){
cout<<"\n";
for(int b=0;b<NCS;b++)
cout<< Mat[i][b]<< "\t";
}
cout<<endl;
}
void Table::swapRows(int I,int J){
double temp;
for(int i=0;i<NRS;i++){
temp = Mat[J][i];
Mat[J][i] = Mat[I][i];
Mat[I][i] = temp;
}
}
void Table::inputTable(){
for(int i=0;i<NRS;i++){
for(int j=0;j<NCS;j++)
cin>>Mat[i][j];
}
}
void main()
{
Table Mat1(5,5);
Mat1.inputTable();
Table Mat2(Mat1);
Mat2.swapRows(1,3);
cout << "Mat1 :"<<endl;
Mat1.printTable();
cout << "Mat2 :"<<endl;
Mat2.printTable();
}
ادعو لينا



