int compar(const void *a, const void *b){
	char c1=*(const char*)a, c2=*(const char*)b; 
	return c1-c2;
}

_Bool issorted(char *balls){
	int i,state;
	state=0;
	for(i=0;i<NUMBALLS;i++){
		if(balls[i]<state)return false;
		if(balls[i]>state)state=balls[i];
	}
	return true;
}

void printout(char *balls){
	int i;
	char str[NUMBALLS+1];
	for(i=0;i<NUMBALLS;i++)str[i]=balls[i]==0?'r':balls[i]==1?'w':'b';
	printf(,str);
}

int main(void) {
	char balls[NUMBALLS]; 
	int i;
	srand(time(NULL)); 
	rand(); 
	        
	
	for(i=0;i<NUMBALLS;i++)balls[i]=(double)rand()/RAND_MAX*3;
	while(issorted(balls)){ 
		printf();
		printout(balls);
		for(i=0;i<NUMBALLS;i++)balls[i]=(double)rand()/RAND_MAX*3;
	}
	printf();
	printout(balls);
	qsort(balls,NUMBALLS,sizeof(char),compar); 
	if(issorted(balls)){ 
		printf();
		printout(balls);
	} else {
		printf();
		printout(balls);
	}
	return 0;
}