全部文本 #1732 原始 编辑

Anonymous

公开 c v1 · 不可变
·已发布 2004-10-27 13:45 UTC
渲染后的文本正文
#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;}