Hello I have a problem with this task:
Function 1 by iteration: input (n, a)
There are elements of the array of keyboard are read.
2 by means of iteration function: output (n, a)
It is formatted to display the elements of the array on the screen.
3 function using iteration: copy (a, start number, a, b, target)
Universal function for copying arrays
There is a section of the array a (number of elements, first starting with the index) in the
Array b is copied from the target index. Example: a: 1 4 6 8 2 9 b: 1 0 2 3 4 5 6
Result of copy (a, 1.3, b, 2) b: 1 0 4 6 8 5 6
Note: For space, the calling function is responsible.
4 function recursively: mix (m, a, n, b, c)
It, the elements of two ascending sorted array a (m elements) and b (n elements)
are mixed together and stored in an array c in ascending order.
Example: a 1 b 4 5 6 9 2 4 11 result in c 11. 1 2 4 4 5 6 9
This should be programmed as follows recursively.
If a contains no elements: copy by copy b to c, and you're done.
If b has no elements: a means to copy c copy and you're done.
Otherwise the maximum of all elements of a and b is to be determined.
This is a [m-1], or b [n-1], as both are arrays sorted.
Is the maximum of a [m-1], then
Copy a [m-1] at the end of c and mix the remaining m-1 elements of a and n elements of b
after c. This is done by the (recursive) calling mix (m-1, a, n, b, c)
B is the maximum of [n-1], then copy analog b [n-1], etc.
Example of an intermediate step, wherein the three elements have been copied 6 9 11 to c:
11th a 1 4 5 6 9 2 4 11 b and in c ----- 6 9
The maximum of the remaining elements of a and b is a [2] = 5 It is copied to c
a 1 4 5 6 2 4 11 9 11 b result in c. ---- 5 6 9
Then is only the remainder of a: 1 to 4 and the remainder of b: 2 4 in the first 4 elements of c
mix using a recursive call.
My Programm is looking so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include <iostream>
#include <iomanip>
#include "fkt_PROTO.h"
using namespace std;
int main()
{
char auswahl;
int anzahl;
const int index=20;
double inputRAY[index];
cout << "Hi \n"
<< " dummy text.\n"
<< "A. Array length.\n"
<< "B. Array Enter.\n"
<< "C. Print out.\n"
<< "D. Copy.\n"
<< "E. Mix .\n";
cin >> option;
switch (option)
{
case 'a':
case 'A':
cout << "Length of Array?\n";
cin >> anzahl;
case 'B':
case 'b':
input(inputRAY,index,anzahl);
cout << "Enter\n\n";
cin.get();
break;
case 'C':
case 'c':
cout << "Print out Array? ...\n";
output(inputRAY, anzahl);
cout << "Happy ??\n";
}
return (0);
}
#include <iostream>
#include <iomanip>
using namespace std;
int output(double inputRAY[],int anzahl)
{
for (int zaehler=0; zaehler<anzahl; zaehler++)
{
cout << "What is in this point " << zaehler << endl
<< "in Array" << zaehler+1 << ". is this:" <<endl
<< inputRAY[zaehler];
}
return (0);
}
double input(double array[], int, int);
double output(double array[], int);
|
I have an error for input and output .
Can somebody help me?