Error in check_if_orderable
: the expression should have a pointer type to an object.
I do not understand how to specify this type? I understand that you need to put something in front of the ARR (something. Marr [0]), and how it does not enter.
and in main check_if_oderable (arr);
says ARR is not defined.
I understand that I don’t get a garbage, but I can not stop. Help me please. )
/ * 4. Make a subroutine that checks the specified array from n numbers to orderly
Ascending (k = 1 - if an array is ordered, k = 0 - otherwise).
With its help, in the main program, process two arrays and one that is not ordered -
reset (using another subroutine). * /
#Include & lt; iostream & gt;
Using Namespace STD;
#Define N 7 // Number of numbers in the array
Void ENTER_NUMBERS ();
Void Check_IF_ORDERABLE (INT & AMP; ARR); // Check array is ordered
INT MAIN ()
{
ENTER_NUMBERS ();
Check_if_orderable (ARR);
Return 0;
}
Void ENTER_NUMBERS ()
{
INT ARR [N] {};
int i;
for (i = 1; i & lt; = n; i ++)
{
COUT & LT; & LT; "Please Enter Some Number" & lt; & lt; i & lt; & lt; ":";
CIN & GT; & GT; Arr [i];
}
}
Void Check_IF_ORDERABLE (INT & AMP; ARR)
{
int i;
for (i = 1; i & lt; = n; i ++)
{
int prev, next;
Prev = Arr [0]; // Error: the expression must have a type of pointer to the volume
next = Arr [1]; // Error: the same
if (prev & lt; next)
{
prev = Arr [i + 1]; // Error: the same
next = Arr [i + 1]; // Error: the same
}
ELSE.
{
COUT & LT; & LT; "This Array Is Not Orderable.";
}
}
}
Answer 1, Authority 100%
Announcement
void check_if_orderable (int & amp; arr)
Means the Chtio You pass to the link int
function, and not a pointer, as you probably thought (here & amp;
– Not taking the address).
You need to just replace & amp;
on *
:
void check_if_orderable (int * arr)
So, as it is written with you – you are trying to turn to an integer as a massif, which is meaningless. What is the third element of the number 5? 🙂 This is about it and says the compiler – that there should be a pointer.