Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[])
- {
- void Testfall(int id, short array, int length);
- void sortiereAbsteigend(short* array, int length);
- short* array[12] = {5, 16 ,7, 12, 1, 33, 100, 67, 45, 11, 21, 27};
- printf("Testrahmen \n");
- Testfall(1, array, 2);
- Testfall(2, array, 6);
- Testfall(3, array, 12);
- return 0;
- }
- void Testfall(int id, short* array, int length)
- {
- //printf("Testfall%d Ein: %s Aus: %s\n", id, array, sortiereAbsteigend(array, length);
- }
- void sortiereAbsteigend(short* array, int length)
- {
- short max;
- int index;
- short temp;
- int i, j;
- max = 0;
- for(i = 0; i < length; i++) {
- array[i] = temp; // ersten Wert der Teilfolge sichern
- // Maximalwert suchen:
- max = -32768;
- for(j = i; j < length; j++) {
- if(array[j] >= max) {
- max = array[j];
- index = j;
- }
- }
- // gefundenen Maximalwert an erste Stelle setzen
- array[i] = array[index];
- // und mit erstem Datensatz tauschen:
- array[index] = temp;
- }
- }
Add Comment
Please, Sign In to add comment