#include #include #include #define len 40 struct test { unsigned int saldo; unsigned int name; }; int main() { int i, x; struct test test[len]; struct test tmp; for (i = 0; i < len; i++) test[i].saldo = random(); for (i = 0; i < len; i++) { int idx = 0; unsigned int biggest = 0; for (x = i; x < len; x++) { if (biggest < test[x].saldo) { biggest = test[x].saldo; idx = x; } } if (idx) { memcpy(&tmp, &test[i], sizeof(struct test)); memcpy(&test[i], &test[idx], sizeof(struct test)); memcpy(&test[idx], &tmp, sizeof(struct test)); } } for (i = 0; i < len; i++) printf("%d\n", test[i].saldo); return 0; }