This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: It will merge the two array into a sorted array. 1 2 5 6 7 9 10 11 12 13 18 19 20 21 22 24 29 30 32 35 #include <iostream> using namespace std; void someFunction( int , int , int , int, int, int ); int main() { const int size = 20, size1 = 10, size2 = 10; int a = {1, 5, 6, 9, 10, 12, 19, 20, 22, 29}; int b = {2, 7, 11, 13, 18, 21, 24, 30, 32, 35}; int c[size] = { 0 }; someFunction(a, b, c, size, size1, size2); for (int i = 0; i < size; i++) { cout << c[i] << “ “; } return 0; } void someFunction(int s, int t, int u, int size, int size1, int size2) { int i, j, k; i = j = k = 0; while ( (i < size1) && (j < size2)) { if (s[i] < t[j]) { u[k] = s[i]; i++; } else { u[k] = t[j]; j++; } k++; } if (i< size1) for (int n = i; n < size1; n++) u[k++] = s[n]; else if (j < size2) for (int n = j; n < size2; n++) u[k++] = t[n]; }...
View
Full Document
 Spring '09
 P.J.Deitel
 Void type, int freq, const int SIZE

Click to edit the document details