1. ## Exercise with MinMax

hello,
to be honest i don't really know how to do that exercise and it would be great if someone could help with it.

An integer
N and a sequence of N integers are given. Find the order number of the last extremal (that is, minimal or maximal) element of the sequence.

2. I don't know what you mean by "the order number", but the rest is quite simple. Iterate through the array and keep two indices, one for the lowest value and one for the highest. Also keep track of which index was highest or lowest last and you're done.

3. by the wrong posted

4. I have to do it without array that the first thing.
Here I have some solution which should apear in the console if program works.

5. Originally Posted by GReaper
I don't know what you mean by "the order number", . . .
Maybe it means:
How many numbers are to input? 5
Input five numbers:

6. Originally Posted by Jcobbe
I have to do it without array that the first thing.
Here I have some solution which should apear in the console if program works.

Ok, that is in this example 5 + 2.
minimal or maximal
And(!) not or because the result in the example is seven.

7. Oh, so it simply wants the index. Of course, this can be done without an array too, just decide for min and max as soon as you input the number and keep track of them in three variables, one for min, one for max and one for the last extremal index.

8. Originally Posted by GReaper
Oh, so it simply wants the index. Of course, this can be done without an array too, just decide for min and max as soon as you input the number and keep track of them in three variables, one for min, one for max and one for the last extremal index.
Can u show me how can i do it because i still dont know

9. An idea, take the input numbers through two (first(x) - last(x)) and sort the last part for maximum and minimum, and then add this two numbers.

I hope that was a right idea . . .

10. Originally Posted by Kernelpanic
An idea, take the input numbers through two (first(x) - last(x)) and sort the last part for maximum and minimum, and then add this two numbers.

I hope that was a right idea . . .
Yeah i get it but now i have to write it

11. What's stopping you from writing it?

12. Originally Posted by Jcobbe
Yeah i get it but now i have to write it
Originally Posted by laserlight
What's stopping you from writing it?
If that not a "Last-minute-Year-Project" then make your brain clear befor:

Examples:
http://edle-troepfchen.de/wp-content...rger-gross.jpg

https://cdn1.wine-searcher.net/image...l-10632678.jpg

13. Originally Posted by Kernelpanic
An idea, take the input numbers through two (first(x) - last(x)) and sort the last part for maximum and minimum, and then add this two numbers.

Ok, I have reset my brain and this is the idea as a program (English version, almost):

Code:
```//Aus der 2ten Hälfe von Nummern die niedrigste und die höchste
//herausfinden und addieren - 6./7. Dez. 2018
//From the 2nd half of numbers the lowest and the highest

#include <stdio.h>
#include <stdlib.h>

#define MAX 20

int maximum_aus_feld(int *eingabe, int groesse);
int minimum_aus_feld(int *eingabe, int groesse);

int main(void)
{
//The right field is to browsed
int eingabe_feld[MAX];
int rechtes_feld[MAX / 2];

int *feld_eingabe_zgr = &eingabe_feld[0];
int *feld_rechts_zgr = &rechtes_feld[0];

int anzahl, eingabe;
int rechte_haelfte;

printf("\nWie viele Zahlen eingeben?: ");
scanf("%d", &anzahl);

//Eingaben 0 bis über MAX abfangen
if (anzahl == 0)
{
printf("\nFalsche Eingabe!\n");
exit(0);
}
else if (anzahl > MAX)
{
printf("\nMaximum sind 20 Zahlen!\n");
exit(0);
}
else
{
for (int i = 0, j = 1; i < anzahl; i++)
{
printf("Nummer:%2d = ", j++);
scanf("%3d", &eingabe);
eingabe_feld[i] = eingabe;
if (anzahl == 1)
{
printf("\nOrder number = %2d", eingabe_feld[i]);
exit(0);
}
else continue;
}
}

//And catch(?) 2 + 3
if (anzahl == 2)
{
int i = 0;
printf("\nOrder number = %2d", eingabe_feld[i + 1]);
exit(0);
}
else if (anzahl == 3)
{
printf("\nOrder number = %2d", (eingabe_feld[1] + eingabe_feld[2]));
exit(0);
}

printf("\nIhre Eingabe war: ");
for (int i = 0; i < anzahl;)
{
printf("%3d", feld_eingabe_zgr[i++]);
}

//Hälfte der Anzahl, odd or even input quantity
if (anzahl % 2 == 0)
{
rechte_haelfte = anzahl / 2;
}
else
{
rechte_haelfte = ((anzahl / 2) + 1);
}

//Without "größer gleich: >=" error with odd input numbers (quantity)
for (int i = anzahl, j = 1, z = 0; i >= rechte_haelfte; i--, j++, z++)
{
rechtes_feld[z] = eingabe_feld[anzahl - j];
}
//Ordnung muß sein! ;)
printf("\nOrder number = %3d", (maximum_aus_feld(feld_rechts_zgr, rechte_haelfte)
+ minimum_aus_feld(feld_rechts_zgr, rechte_haelfte)));

printf("\n");
return(0);
}

int maximum_aus_feld(int *eingabe, int groesse)
{
//Auf Anfang setzen - Put to the beginning
int maximum = eingabe[0], i;
for(i = 1; i < groesse; i++)
{
//If "eingabe[]"(Input) greater than maximum is eingabe[]
if(eingabe[i] > maximum)
{
maximum = eingabe[i];
}
}
return maximum;
}

int minimum_aus_feld(int *eingabe, int groesse)
{
int minimum = eingabe[0], i;
for(i = 1; i < groesse; i++)
{
//The same like maximum only "<"
if(eingabe[i] < minimum)
{
minimum = eingabe[i];
}
}
return minimum;
}```
Output examples: