All pastes #1732 Raw Edit

Anonymous

public c v1 · immutable
#1732 ·published 2004-10-27 13:45 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <string.h>#define len	40struct 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;}