bubbelsort ... Problem schon beim vertauschen von Zahlen



  • hi,

    ich versuche Bubbelsort zu implementieren. Ich hab das aufgeteilt in verschiedenen Datein (damit ich die Funktionen später für anderen Sortier-Algorithmen benutzen kann):

    swap.hpp:

    void (int *pa, int *pb)
    {
    	int temp = *pa;
    	*pa = *pb;
    	*pb = temp;
    }
    

    bubblesort.hpp

    #include "swap.hpp"
    
    bool bubblesort (int *array, int size)
    {
    	for (int i = 0; i <= size - 1; i++)
    	{
    		for (int j = 0; j <= size; j++)
    			if (array[j] > array[j + 1])
    				swap (array[j], array[j + 1]);
    	}
    }
    

    test.cpp

    #include "bubblesort.hpp"
    
    int main ()
    {
    	return 0;
    }
    

    g++ test.cpp

    In file included from bubblesort.hpp:1,
                     from test.cpp:1:
    swap.hpp:1: error: expected unqualified-id before "int"
    swap.hpp:1: error: expected `)' before "int"
    swap.hpp:1: error: expected `,' or `;' before "int"
    In file included from test.cpp:1:
    bubblesort.hpp: In function `bool bubblesort(int*, int)':
    bubblesort.hpp:9: error: `swap' undeclared (first use this function)
    bubblesort.hpp:9: error: (Each undeclared identifier is reported only once for each function it appears in.)
    

    Die Swap-Funktion ist Volkard's Kurs nachempfunden (http://www.volkard.de/vcppkold/bubble_sort.html) und sollte fast identisch sein.

    Vielen Dank!

    mfg

    Joachim



  • Die Swap-Funktion ist Volkard's Kurs nachempfunden (http://www.volkard.de/vcppkold/bubble_sort.html) und sollte fast identisch sein.

    Vielen Dank!

    mfg

    Joachi
    [/quote]

    warum hat die funktion keinen namen?


Anmelden zum Antworten