sortiranje cega
unknown
c_cpp
2 years ago
752 B
1
Indexable
Never
#include <stdio.h> void sortiraj(float *niz, int vel) { float *pok1 = niz, *pok2 = NULL; float *pok_na_kraj = niz + vel; while (pok1 < pok_na_kraj) { pok2 = pok1 + 1; while (pok2 < pok_na_kraj) { if (*pok1 > *pok2) { int temp = *pok1; *pok1 = *pok2; *pok2 = temp; } pok2++; } pok1++; } } int main() { printf("sortiraj mog "); float niz[] = {5, 4, 0, 2, 10, 11, 1}; int vel = sizeof (niz) / sizeof (niz[0]); sortiraj(niz, vel); float* pok = niz; float* pok_na_kraj = niz + vel; while (pok < pok_na_kraj) { printf("%.2f ", *pok++); } return 0; }