void merge(int *, int, int, int);
void sort_merge(int *w, int lower, int higher)
{
int avg;
if (lower < higher)
{
avg = (lower + higher) / 2;
sort_merge(w, lower, avg);
sort_merge(w, avg + 1, higher);
merge(w, lower, higher, avg);
}
return;
}
void merge(int *w, int lower, int higher, int avg)
{
int i, z, v, c[50];
i = lower;
v = lower;
z = avg + 1;
while (i <= avg && z <= higher)
{
if (w[i] < w[z])
{
c[v] = w[i];
v++;
i++;
}
else
{
c[v] = w[z];
v++;
z++;
}
}
while (i <= avg)
{
c[v] = w[i];
v++;
i++;
}
while (z <= higher)
{
c[v] = w[z];
v++;
z++;
}
for (i = lower; i < v; i++)
{
w[i] = c[i];
}
}
void timefunction()
{
long long number = 0;
for (long long i = 0; i != 20000000; ++i)
{
number += 5;
}
}
int main()
{
cout << "THE MERGE SORT FOR CYBERNETICS LTD.\n" << endl << endl;
int w[20], i, h[20];
cout << "ENTER DATA ARRAY ELEMENTS:\n";
for (i = 0; i < 15; i++)
{
cout << "\n";
cin >> w[i];
}
cout << "\n\n";
sort_merge(w, 0, 14);
cout << "MERGE-SORTED ARRAY:\n";
for (i = 0; i < 15; i++)
{
cout << w[i] << " ";
}
cout << "\n\n";
cout << "ENTER DATA ARRAY ELEMENTS:\n";
for (i = 0; i < 15; i++)
{
cout << "\n";
cin >> h[i];
}
cout << "\n\n";
sort_merge(h, 0, 14);
cout << "MERGE-SORTED ARRAY:\n";
for (i = 0; i < 15; i++)
{
cout << h[i] << " ";
}
You were asked in your previous thread to use code tags when posting code. If you're not going to make the slightest bit of effort to make your posts readable, why should we spend the slightest bit of effort helping you?