+ 1

/*Merging two arrays in third array in sorted order using merge sort,duplicate values in both the arrays are sorted once only in

//not working /*Merging two arrays in third array in sorted order using merge sort,duplicate values in both the arrays are sorted once only in third array*/ #include<iostream.h> #define MAX 100 class Asending { int arr[MAX]; public: int size; Ascending() { size=0; } Ascending(int n) { size=n; } void input(); void sort(); void displayList(); Ascending merge(Ascending d); }; void Ascending::input() { for(int i=0;i<size;i++) { cout<<"enter a no"; cin>>arr[i]; } sort(); displayList(); } void Ascending::sort() { int i,j,temp; for(i=0;i<size-1;i++) { for(j=i+1;j<size;j++) { if(arr[i]>arr[j]) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } } } void Ascending::displayList() { cout<<"Array element:"; for(int i=0;i<size;i++) { cout<<arr[i]<<" "; } cout<<endl; } Ascending Ascending::merge(Ascending d) { Ascending temp; temp.size=size+d.size; int i,j,k,t; for(i=j=k=0; ;k++) { if(arr[i]<d. arrLiJ) { temp.arr[k]=arr[i++]; } else if(arr[i]==d.arr[j]) { temp.arr[k]=arr[i++]; j++; temp.size--; } else { temp.arr[k]=d.arr[j++]; } if(i==size||j===d.size) { break; } } for(k++;i<size;i++) { temp.arr[k++]=arr[i]; } for( ;j<d.size;j++) { temp.arr[k++]=d.arr[j]; } for(i=0;i<temp. size;i++) { return temp; } } void main() { Ascending al(5),a2(5),a3( 10); al.input(); a2.input(); a3==a1.merge(a2); a3.displayList(); getch(); } //showing errors

30th Aug 2017, 6:23 PM
Sayan Chakraborty
Sayan Chakraborty - avatar
5 Respostas
+ 1
Compiling ..\PROJECTS\ARRAY.CPP Error ..\PROJECTS\ARRAY.CPP 20: Type name expected Error ..\PROJECTS\ARRAY.CPP 20:Multiple Declaration for 'Ascending' Error ..\PROJECTS\ARRAY.CPP 20: Declaration Missing ; Warning ..\PROJECTS\ARRAY.CPP 12: Functions containing missing return statement are not expandable inline Warning ..\PROJECTS\ARRAY.CPP 16: Functions containing missing return statement are not expandable inline Error ..\PROJECTS\ARRAY.CPP 22: Type qualifier 'Asending' must be struct or class name Error ..\PROJECTS\ARRAY.CPP 22: Declaration terminated incorrectly
30th Aug 2017, 6:35 PM
Sayan Chakraborty
Sayan Chakraborty - avatar
+ 1
corrected them but now shows 3 error
30th Aug 2017, 6:41 PM
Sayan Chakraborty
Sayan Chakraborty - avatar
+ 1
not getting it
30th Aug 2017, 6:45 PM
Sayan Chakraborty
Sayan Chakraborty - avatar
+ 1
oh I see
30th Aug 2017, 6:48 PM
Sayan Chakraborty
Sayan Chakraborty - avatar
30th Aug 2017, 6:58 PM
Sayan Chakraborty
Sayan Chakraborty - avatar