SlideShare uma empresa Scribd logo
1 de 6
Baixar para ler offline
Damascus University 
Faculty of Information Technology Engineering 
Shapes and calculate 
(area and contour) / C++ OOP concept
:ODEC 
#include<iostream> 
using namespace std; 
struct elem 
{ 
int col; 
double val; 
elem* next; 
}; 
struct HoleMat 
{ elem* mat[200]; }; 
//////////////////////////////////////////////////////////////////////////////////// 
void insert(elem* &reshead,int j,double x) 
{ 
elem* p=new elem; 
p->col=j; //intilizing node 
p->val=x; 
p->next=NULL; 
if(reshead==NULL) 
{ 
reshead=p; 
} 
else 
if(reshead->col > j) 
{ 
p->next= reshead; 
reshead=p; 
} 
else 
{ 
elem* r; 
r=reshead; 
while( (r->next != NULL)&&(r->next->col < j) ) 
{ 
r=r->next; 
}; 
p->next = r->next; 
r->next=p; 
} 
}; 
bool change(HoleMat &a,int n,int colom,int value) // to change the value if there is another value ((at the same place)) 
{ 
elem* ph; 
for(int i=1; i<=n; i++) 
{ 
ph=a.mat[i]; 
while (ph!=NULL) 
{ 
if(ph->col == colom) 
{ 
ph->val=value; 
return true; 
} 
else 
{ 
ph=ph->next; 
} 
} 
} 
return false; 
}; 
void ReadHMat(HoleMat& a,int n,int &maxcol) 
{ 
maxcol=-4; 
char w=' '; 
int j1,i1; 
double e1; 
for(int i=0; i<200; i++) ///creatig NULL array; 
{ 
a.mat[i]=NULL;
}; 
do 
{ 
cout<<"the element: n"; 
cin>>e1; 
cout<<"the row number: "<<" <= "<<n<<endl; 
cin>>i1; 
cout<<"the colom number: n"; 
cin>>j1; 
if(change(a,n,j1,e1) ) //change the value with th NEW 
{ 
cout<<"there is an elem at the same colom(changed) !! reputn"; 
} 
else 
insert(a.mat[i1],j1,e1); 
if(j1>maxcol) //find max col for matrix 
maxcol=j1; 
start: cout<<"read element again?!!(y or n).. :n"; 
cin>>w; 
if( (w!='y')&&(w!='n')) 
goto start; 
} 
while(w != 'n'); 
}; 
void WriteHMat(HoleMat a,int n,int maxcol) 
{ 
for(int i=1; i<= n; i++) 
{ 
if(a.mat[i] == NULL) //for print 0 whole line 
for(int j=1; j<=maxcol;j++) 
{ 
cout<<" 0 "; 
} 
cout<<endl; 
elem* ls =a.mat[i]; 
int k=1; 
while (ls != NULL) 
{ 
if(ls->col == k) 
{ 
cout<<"( "<< ls->col<<" )| " <<ls->val<<" "; 
ls=ls->next; 
} 
else 
{ cout<<" 0 "; } 
k++; 
} 
if( (k != maxcol)&&( k!= 1) ) // to complet the line with 0 
for(int q=k; q<=maxcol; q++) 
cout<<" 0 "; 
if(a.mat[i] != NULL) //to Not print spaces!! 
cout<<endl; 
};//for 
}; 
void putcurrent(elem*& head,elem* &current,double v1,int c1) //& current 
{ 
elem* temp=new elem; 
temp->col=c1; 
temp->val=v1; 
temp->next=NULL; 
if(current==NULL) 
{ 
head=temp; 
current=temp; 
} 
else 
{
current->next = temp; 
current = current->next; 
} 
}; 
void addmat(HoleMat a,HoleMat b,HoleMat& res,int n1) // & res 
{ 
for(int i=0; i<200; i++) ///creatig NULL array to max 200; 
{ 
res.mat[i]=NULL; 
}; 
for(int i=1; i<= n1 ;i++) 
{ 
elem* p1=a.mat[i]; 
elem* p2=b.mat[i]; 
elem* current; 
current=NULL; 
while( (p1 != NULL)&&(p2 !=NULL) ) //comparing and put the least.. 
{ 
if(p1 ->col < p2->col) 
{ 
putcurrent(res.mat[i],current,p1->val,p1->col); 
p1 = p1->next; 
} 
else if (p2 ->col < p1->col) 
{ 
putcurrent(res.mat[i],current,p2->val,p2->col); 
p2 = p2->next; 
} 
else // == 
{ 
double sum=p1->val + p2->val ; 
putcurrent(res.mat[i],current,sum,p1->col); 
p1 = p1->next; 
p2 = p2->next; 
} 
};//while 
while(p1 != NULL) //for what is left in a .. 
{ 
putcurrent(res.mat[i],current,p1->val,p1->col); 
p1 = p1->next; 
}; 
while(p2 != NULL) //for what is left in b .. 
{ 
putcurrent(res.mat[i],current,p2->val,p2->col); 
p2 = p2->next; 
}; 
};//for 
}; 
double SumHMat(HoleMat z,int n) 
{ 
double sum=0; 
elem* ph; 
for(int i=1; i<=n; i++) 
{ 
ph=z.mat[i]; 
while (ph != NULL) 
{ 
sum=sum + ph->val; 
ph=ph->next; 
} 
}; 
return sum; 
}; 
double MaxMat(HoleMat y,int n) 
{ 
double max; 
int maxrow,maxcol; 
int i=1; // find the first row != NUll to give Max an intilize value 
elem* t; //auxitiare 
while ( y.mat[i] == NULL) 
{ i++ ; }; 
max=y.mat[i] ->val; 
for(int j=i; j<=n;j++)
{ 
t=y.mat[j]; 
while(t != NULL) 
{ 
if( t->val > max) 
{ 
max= t->val; 
maxrow=j; 
maxcol=t->col; 
} 
t=t->next; 
}; 
}; 
// just print max's node 
cout<<"( "<<maxrow<<" , "<<maxcol<<" )| " <<max<<" "; 
return max; 
}; 
////////////////////////////////////////////////////////////////////////////////// 
void main() 
{ 
HoleMat a,b,res,z,y; 
int max; 
char c=' '; 
int n,n1,n2; //row dimention.. 
while( c != '0') 
{ 
cout<<"|----------------------------------------------------------------------|n"; 
cout<<"| CHOICE MENU |n" ; 
cout<<"|-----|----|-----------------------------------------------------------|n"; 
cout<<"| |(1)-| Read your matrix: 'press (1) ' |n"; 
cout<<"| --|----|------------------------------------------- |n"; 
cout<<"| |(2)-| writeMatrix : 'press (2) ' |n"; 
cout<<"| --|----|------------------------------------------- |n"; 
cout<<"| |(3)-| Add two matrix 'press (3) ' |n"; 
cout<<"| --|----|------------------------------------------- |n"; 
cout<<"| |(4)-| sum all matrix elements : 'press (4) ' |n"; 
cout<<"| --|----|------------------------------------------- |n"; 
cout<<"| |(5)-| Find Max element int the Matrix : 'press (5) ' |n"; 
cout<<"| --|----|------------------------------------------- |n"; 
cout<<"| |(0)-| to EXIT.. 'press (0) ' |n"; 
cout<<"|-----|----|-----------------------------------------------------------|n"; 
cout<<"|----------------------------------------------------------------------|n"; 
cout<<"enter your choice : "; 
cin>>c; 
switch(c) 
{ 
case '1': { 
cout<<"enter the all row(max row number) number: n"; 
cin>>n; 
ReadHMat(a,n,max); 
cout<<"------------------------------------------------------------------------n"; 
break; 
}; 
case'2': { 
cout<<"WRITEMAT...............n"; 
WriteHMat(a,n,max); 
cout<<"---------------------------------------------------------------------------- n"; 
break; 
}; 
case'3': { 
cout<<"FIrst matrix: n"; 
cout<<"enter the all row(max row number) number: n"; 
cin>>n1; 
ReadHMat(a,n1,max); 
WriteHMat(a,n1,max); 
// 
cout<<"Second matrix: n"; 
cout<<"enter the all row(max row number) number: n"; 
cin>>n2; 
ReadHMat(b,n2,max);
WriteHMat(b,n2,max); 
if(n1 != n2) 
{ 
cout<<"cannot do the add n1!=n2 n"; 
break; 
} 
addmat(a,b,res,n1); 
cout<<"******the RES*******n"; 
WriteHMat(res,n1,max); 
break; 
}; 
case'4':{ 
cout<<"enter the all row(max row number) number: n"; 
cin>>n; 
cout<<"Put the matrix: n"; 
ReadHMat(z,n,max); 
WriteHMat(z,n,max); 
cout<<"the sum of all elements = n"; 
cout<<SumHMat(z,n)<<endl; 
break; 
}; 
case'5': { 
cout<<"enter the all row(max row number) number: n"; 
cin>>n; 
cout<<"Put the matrix: n"; 
ReadHMat(y,n,max); 
WriteHMat(y,n,max); 
cout<<"the Max number in it= "<<MaxMat(y,n)<<endl; 
break; 
}; 
case'0': 
{ 
cout<<"End Program..My wishes :D....n"; 
break; 
}; 
default: { cout<<"error value..n"; break;}; 
}; 
};//while 
system("pause");

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

week-5x
week-5xweek-5x
week-5x
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Tower of HANOI
Tower of HANOITower of HANOI
Tower of HANOI
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functions
 
Cpp programs
Cpp programsCpp programs
Cpp programs
 
C questions
C questionsC questions
C questions
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
TSP algorithm (Computational Thinking) Dropbox
TSP algorithm (Computational Thinking) DropboxTSP algorithm (Computational Thinking) Dropbox
TSP algorithm (Computational Thinking) Dropbox
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
Freeing Tower Bridge
Freeing Tower BridgeFreeing Tower Bridge
Freeing Tower Bridge
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
Conversion of data types in java
Conversion of data types in javaConversion of data types in java
Conversion of data types in java
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Ct es past_present_future_nycpgday_20130322
Ct es past_present_future_nycpgday_20130322Ct es past_present_future_nycpgday_20130322
Ct es past_present_future_nycpgday_20130322
 
C++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLESC++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLES
 
Standing the Test of Time: The Date Provider Pattern
Standing the Test of Time: The Date Provider PatternStanding the Test of Time: The Date Provider Pattern
Standing the Test of Time: The Date Provider Pattern
 

Destaque

C++ by shantu
C++ by shantuC++ by shantu
C++ by shantuShant007
 
Presentation of 3rd Semester C++ Project
Presentation of 3rd Semester C++ ProjectPresentation of 3rd Semester C++ Project
Presentation of 3rd Semester C++ ProjectChandan Gupta Bhagat
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentationSaad Symbian
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programsharman kaur
 

Destaque (7)

C++ by shantu
C++ by shantuC++ by shantu
C++ by shantu
 
C++ super market
C++ super marketC++ super market
C++ super market
 
Presentation of 3rd Semester C++ Project
Presentation of 3rd Semester C++ ProjectPresentation of 3rd Semester C++ Project
Presentation of 3rd Semester C++ Project
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentation
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Basic c++ programs
Basic c++ programsBasic c++ programs
Basic c++ programs
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 

Semelhante a Damascus University Faculty Shapes Calculate C++ OOP

#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docxajoy21
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docxAdamq0DJonese
 
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfData StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfrozakashif85
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfforladies
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdfpasqualealvarez467
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdfanujmkt
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and CEleanor McHugh
 
Hi,you covered mostly things.there are issue to point and link poi.pdf
Hi,you covered mostly things.there are issue to point and link poi.pdfHi,you covered mostly things.there are issue to point and link poi.pdf
Hi,you covered mostly things.there are issue to point and link poi.pdfaryan9007
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
Please fill in the code to run the program based on the following in.pdf
Please fill in the code to run the program based on the following in.pdfPlease fill in the code to run the program based on the following in.pdf
Please fill in the code to run the program based on the following in.pdfamarnathmahajansport
 
This is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfThis is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfkostikjaylonshaewe47
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statementsMomenMostafa
 
C++ adt c++ implementations
C++   adt c++ implementationsC++   adt c++ implementations
C++ adt c++ implementationsRex Mwamba
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 

Semelhante a Damascus University Faculty Shapes Calculate C++ OOP (20)

#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
 
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfData StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdf
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
Hi,you covered mostly things.there are issue to point and link poi.pdf
Hi,you covered mostly things.there are issue to point and link poi.pdfHi,you covered mostly things.there are issue to point and link poi.pdf
Hi,you covered mostly things.there are issue to point and link poi.pdf
 
Dsprograms(2nd cse)
Dsprograms(2nd cse)Dsprograms(2nd cse)
Dsprograms(2nd cse)
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
Please fill in the code to run the program based on the following in.pdf
Please fill in the code to run the program based on the following in.pdfPlease fill in the code to run the program based on the following in.pdf
Please fill in the code to run the program based on the following in.pdf
 
This is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfThis is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdf
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 
week-18x
week-18xweek-18x
week-18x
 
week-17x
week-17xweek-17x
week-17x
 
C++ adt c++ implementations
C++   adt c++ implementationsC++   adt c++ implementations
C++ adt c++ implementations
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 

Mais de kinan keshkeh

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)kinan keshkeh
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm kinan keshkeh
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...kinan keshkeh
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graphkinan keshkeh
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_unitskinan keshkeh
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_listskinan keshkeh
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked listkinan keshkeh
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointerskinan keshkeh
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfileskinan keshkeh
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfileskinan keshkeh
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_recordskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templateskinan keshkeh
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphismkinan keshkeh
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritancekinan keshkeh
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces kinan keshkeh
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays kinan keshkeh
 

Mais de kinan keshkeh (20)

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
 

Último

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 

Último (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

Damascus University Faculty Shapes Calculate C++ OOP

  • 1. Damascus University Faculty of Information Technology Engineering Shapes and calculate (area and contour) / C++ OOP concept
  • 2. :ODEC #include<iostream> using namespace std; struct elem { int col; double val; elem* next; }; struct HoleMat { elem* mat[200]; }; //////////////////////////////////////////////////////////////////////////////////// void insert(elem* &reshead,int j,double x) { elem* p=new elem; p->col=j; //intilizing node p->val=x; p->next=NULL; if(reshead==NULL) { reshead=p; } else if(reshead->col > j) { p->next= reshead; reshead=p; } else { elem* r; r=reshead; while( (r->next != NULL)&&(r->next->col < j) ) { r=r->next; }; p->next = r->next; r->next=p; } }; bool change(HoleMat &a,int n,int colom,int value) // to change the value if there is another value ((at the same place)) { elem* ph; for(int i=1; i<=n; i++) { ph=a.mat[i]; while (ph!=NULL) { if(ph->col == colom) { ph->val=value; return true; } else { ph=ph->next; } } } return false; }; void ReadHMat(HoleMat& a,int n,int &maxcol) { maxcol=-4; char w=' '; int j1,i1; double e1; for(int i=0; i<200; i++) ///creatig NULL array; { a.mat[i]=NULL;
  • 3. }; do { cout<<"the element: n"; cin>>e1; cout<<"the row number: "<<" <= "<<n<<endl; cin>>i1; cout<<"the colom number: n"; cin>>j1; if(change(a,n,j1,e1) ) //change the value with th NEW { cout<<"there is an elem at the same colom(changed) !! reputn"; } else insert(a.mat[i1],j1,e1); if(j1>maxcol) //find max col for matrix maxcol=j1; start: cout<<"read element again?!!(y or n).. :n"; cin>>w; if( (w!='y')&&(w!='n')) goto start; } while(w != 'n'); }; void WriteHMat(HoleMat a,int n,int maxcol) { for(int i=1; i<= n; i++) { if(a.mat[i] == NULL) //for print 0 whole line for(int j=1; j<=maxcol;j++) { cout<<" 0 "; } cout<<endl; elem* ls =a.mat[i]; int k=1; while (ls != NULL) { if(ls->col == k) { cout<<"( "<< ls->col<<" )| " <<ls->val<<" "; ls=ls->next; } else { cout<<" 0 "; } k++; } if( (k != maxcol)&&( k!= 1) ) // to complet the line with 0 for(int q=k; q<=maxcol; q++) cout<<" 0 "; if(a.mat[i] != NULL) //to Not print spaces!! cout<<endl; };//for }; void putcurrent(elem*& head,elem* &current,double v1,int c1) //& current { elem* temp=new elem; temp->col=c1; temp->val=v1; temp->next=NULL; if(current==NULL) { head=temp; current=temp; } else {
  • 4. current->next = temp; current = current->next; } }; void addmat(HoleMat a,HoleMat b,HoleMat& res,int n1) // & res { for(int i=0; i<200; i++) ///creatig NULL array to max 200; { res.mat[i]=NULL; }; for(int i=1; i<= n1 ;i++) { elem* p1=a.mat[i]; elem* p2=b.mat[i]; elem* current; current=NULL; while( (p1 != NULL)&&(p2 !=NULL) ) //comparing and put the least.. { if(p1 ->col < p2->col) { putcurrent(res.mat[i],current,p1->val,p1->col); p1 = p1->next; } else if (p2 ->col < p1->col) { putcurrent(res.mat[i],current,p2->val,p2->col); p2 = p2->next; } else // == { double sum=p1->val + p2->val ; putcurrent(res.mat[i],current,sum,p1->col); p1 = p1->next; p2 = p2->next; } };//while while(p1 != NULL) //for what is left in a .. { putcurrent(res.mat[i],current,p1->val,p1->col); p1 = p1->next; }; while(p2 != NULL) //for what is left in b .. { putcurrent(res.mat[i],current,p2->val,p2->col); p2 = p2->next; }; };//for }; double SumHMat(HoleMat z,int n) { double sum=0; elem* ph; for(int i=1; i<=n; i++) { ph=z.mat[i]; while (ph != NULL) { sum=sum + ph->val; ph=ph->next; } }; return sum; }; double MaxMat(HoleMat y,int n) { double max; int maxrow,maxcol; int i=1; // find the first row != NUll to give Max an intilize value elem* t; //auxitiare while ( y.mat[i] == NULL) { i++ ; }; max=y.mat[i] ->val; for(int j=i; j<=n;j++)
  • 5. { t=y.mat[j]; while(t != NULL) { if( t->val > max) { max= t->val; maxrow=j; maxcol=t->col; } t=t->next; }; }; // just print max's node cout<<"( "<<maxrow<<" , "<<maxcol<<" )| " <<max<<" "; return max; }; ////////////////////////////////////////////////////////////////////////////////// void main() { HoleMat a,b,res,z,y; int max; char c=' '; int n,n1,n2; //row dimention.. while( c != '0') { cout<<"|----------------------------------------------------------------------|n"; cout<<"| CHOICE MENU |n" ; cout<<"|-----|----|-----------------------------------------------------------|n"; cout<<"| |(1)-| Read your matrix: 'press (1) ' |n"; cout<<"| --|----|------------------------------------------- |n"; cout<<"| |(2)-| writeMatrix : 'press (2) ' |n"; cout<<"| --|----|------------------------------------------- |n"; cout<<"| |(3)-| Add two matrix 'press (3) ' |n"; cout<<"| --|----|------------------------------------------- |n"; cout<<"| |(4)-| sum all matrix elements : 'press (4) ' |n"; cout<<"| --|----|------------------------------------------- |n"; cout<<"| |(5)-| Find Max element int the Matrix : 'press (5) ' |n"; cout<<"| --|----|------------------------------------------- |n"; cout<<"| |(0)-| to EXIT.. 'press (0) ' |n"; cout<<"|-----|----|-----------------------------------------------------------|n"; cout<<"|----------------------------------------------------------------------|n"; cout<<"enter your choice : "; cin>>c; switch(c) { case '1': { cout<<"enter the all row(max row number) number: n"; cin>>n; ReadHMat(a,n,max); cout<<"------------------------------------------------------------------------n"; break; }; case'2': { cout<<"WRITEMAT...............n"; WriteHMat(a,n,max); cout<<"---------------------------------------------------------------------------- n"; break; }; case'3': { cout<<"FIrst matrix: n"; cout<<"enter the all row(max row number) number: n"; cin>>n1; ReadHMat(a,n1,max); WriteHMat(a,n1,max); // cout<<"Second matrix: n"; cout<<"enter the all row(max row number) number: n"; cin>>n2; ReadHMat(b,n2,max);
  • 6. WriteHMat(b,n2,max); if(n1 != n2) { cout<<"cannot do the add n1!=n2 n"; break; } addmat(a,b,res,n1); cout<<"******the RES*******n"; WriteHMat(res,n1,max); break; }; case'4':{ cout<<"enter the all row(max row number) number: n"; cin>>n; cout<<"Put the matrix: n"; ReadHMat(z,n,max); WriteHMat(z,n,max); cout<<"the sum of all elements = n"; cout<<SumHMat(z,n)<<endl; break; }; case'5': { cout<<"enter the all row(max row number) number: n"; cin>>n; cout<<"Put the matrix: n"; ReadHMat(y,n,max); WriteHMat(y,n,max); cout<<"the Max number in it= "<<MaxMat(y,n)<<endl; break; }; case'0': { cout<<"End Program..My wishes :D....n"; break; }; default: { cout<<"error value..n"; break;}; }; };//while system("pause");