ďťż

Ładny brzuch

witam. czy wie ktoś jak się nazywa i czy wogóle istnieje funkcje w c++, która sortowała by dane z tablicy którą podam jako argument. I ona sortowała by te dane znajdujące się w tablicy (int) rosnąco lub malejąco. z gory thx.



http://www.24bytes.c...bble-sort.html~

std::sort powinno wystarczyć

Masz w <algorithm> algorytm sort()#include <iostream> #include <algorithm> bool DescendingOrder(int a, int b ) { return !(a<B); //a>b } void display(int t[], int s) { for(int i=0; i<s; i++) std::cout << t[i] << " "; std::cout << std::endl; } int main() { int tab[]={1,5,2,7,4,9}; const int size = 6; display(tab, size); std::sort(tab, tab+size); display(tab,size); std::sort(tab, tab+size, DescendingOrder); display(tab,size); std::cin.get(); return 0; }Możesz tez skorzystać z qsort()

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • zsf.htw.pl
  •