void sort_array(int *p ,int m ,int n)
{
   int i = m;
   int j = n;
   int mid = p[(m + n)/2];
   int temp = 0;
   do
   {
       while((p[i] < mid)&&(i < n)) i++;
       while((p[j] > mid)&&( j > m)) j--;
       if(i <= j)
       {
          temp = p[i];
          p[i] = p[j];
          p[j] = temp;
          i++;
          j--;
       }
   }
   while(i <= j);
   if(j >= m)
   {
      sort_array(p , m ,j);
   }
   if(i <= n)
   {
      sort_array(p , i ,n);
   }

}
int cmd( string player, int sorted ) {
    string *quests, text;
    int i, size;
    
    if ( !player ) {
        quests = QUEST_HANDLER->query_quest_names();
        text = "$P$Quest list$P$\nTotal quests on " + mud_name() + " :-\n\n";
    }
    else {
        quests = LIBRARY->query_quests(player);    
        
        if (!quests) {
            add_failed_mess( "That player has not done any "
                "quests.\n" );
            return 0;
        }
        
    if ( sorted ) 
        quests = sort_array( quests, 1 );

        text = "$P$Quest list$P$\nQuests done for player " + player + " :-\n\n";
    }
    size = sizeof(quests);

    for ( i = 0; i < size; i++ ) {
        text += sprintf("%d. %s (%s) %s\n", i + 1, quests[i], 
            QUEST_HANDLER->query_quest_title (quests[i]), 
            quest_text( quests[i] ) );
    }
    
    tell_object( this_player(), text );
    return 1;
} /* cmd() */
/* finds prime numbers in array, size M, and returns pointer to sorted array
   of these prime numbers */
int* prime(int* B, int M){

  /* sort the input array */
  sort_array(B,M);

  /* make a new array to store the prime numbers */
  int* tmp_array = calloc(M,sizeof(int));
  int i;

  /* find primes and populate the temp array */
  int prime_counter = 0; // keep track of the number of prime numbers
  for(i = 0; i < M; ++i){ // iterating through passed array
    if (isPrime(B[i])) {
      tmp_array[i] = B[i];
      ++prime_counter;
    }
  }

  return tmp_array;

  /* The returned array will consist of zeros or prime numbers. Zeros will be
     in indexes that contain NON-prime numbers. I could return an array with
     only the prime numbers, but then you have to figure out what your new array
     size is, and convey this information to the user (or other programmer).
     It's just not worth the trouble.

     You could parse the returned array. All non-zero values are prime numbers
  */
}
Exemple #4
0
SortedArray *create_from_table(HashTable *t)
{
	SortedArray *result = (SortedArray *) malloc(sizeof(SortedArray));

	int size = t->size;

	result->size = size;
	result->words_total = t->elements;
	result->words = (char **) malloc(sizeof(char *) * size);
	result->count = (int *) malloc(sizeof(int) * size);

	memset(result->words, 0, sizeof(char *) * size);
	memcpy(result->count, t->count, sizeof(int) * size);

	for (int i = 0; i < size; i++)
	{
		if (t->count[i])
		{
			result->words[i] = (char *) malloc(sizeof(char) * MAX_WORD_LENGTH);
			strcpy(result->words[i], t->table[i]);	
		}
	}
	sort_array(result);

	return result;
}
Exemple #5
0
int main(void)
{
	srand(time(NULL));
	int SIZE,counter; 
	int a[MAX];
	int b[MAX2]={0};
	printf("Input the size of the first input:");
	scanf("%d",&SIZE);
	while (check_error(SIZE)==0)
	{
		printf("Invalid input enter the size of the input again");
		scanf("%d",&SIZE);
	}
	initialize_array(a,SIZE);
	printf("Input array\n");
	print_array(a,SIZE);
	frequency(a,b,SIZE);
	printf("\nMode for the array is number %d",mode(b));
	printf("\nPrinting histogram\n");
	print_histogram(b);
	printf("Bonus part\n");
	printf("\nArray before sorting\n");
	print_array(a,SIZE);	
	printf("\nArray after sorting\n");
	sort_array(a,SIZE);
	print_array(a,SIZE);
	printf("\n");
}
Exemple #6
0
mixed cmd(string args) {
    object player = this_player();
    mixed replee = player->GetProperty("reply");
    string ret = "";
    string *tmp;
    ret += "Screen: \t\t"+identify(this_player()->GetScreen())+"\n";
    ret += "Terminal: \t\t"+this_player()->GetTerminal()+"\n";
    ret += "Brief mode: \t\t"+ ( (this_player()->GetBriefMode()) ? "on" : "off" )+"\n";
    ret += "Cursefilter: \t\t"+ ( (this_player()->GetParanoia("cursefilter")) ? "on" : "off" )+"\n";
    ret += "Channel message colors: "+ ( (this_player()->GetNoChanColors()) ? "off" : "on" )+"\n";
    ret += "Playerkiller mode: \t"+ ( (this_player()->GetPK()) ? "on" : "off" )+"\n";
    ret += "Mute mode: \t\t"+ GetMuted()+" \n";
    ret += "Gag mode: \t\t"+ GetGagged()+" \n";
    ret += "Wimpy mode: \t\t"+ ( (this_player()->GetWimpy()) ? "on" : "off" )+"\n";
#if efun_defined(compressedp)
    ret += "MCCP mode: \t\t"+(compressedp(this_player()) ? "on" : "off")+"\n";
#endif
#if MINIMAP
    ret += "Minimap mode: \t\t"+ ( this_player()->GetProperty("minimapping") ? "on" : "off" )+"\n";
#endif
    ret += "Annoyblock: \t\t"+ ( (this_player()->GetAnnoyblock()) ? "on" : "off" )+"\n";
    ret += "Reprompt mode: \t\t"+ ( this_player()->GetProperty("reprompt") ? "on" : "off" )+"\n";
    ret += "Screenlock mode: \t"+ ( this_player()->GetProperty("screenlock") ? "on" : "off" )+"\n";
    ret += "Timezone: \t\t"+ ( this_player()->GetProperty("timezone") ? 
            this_player()->GetProperty("timezone") : "None specified" )+"\n";
#ifdef __GET_CHAR_IS_BUFFERED__
    ret += "Charmode: \t\t"+ 
        //( (query_charmode(player) > 0) ? "on" : "off" )+"\n";
        ( (player->GetCharmode()) ? "on" : "off" )+"\n";
#endif
    ret += "Commandecho: \t\t"+ ( this_player()->GetProperty("commandecho") ? this_player()->GetProperty("commandecho") : "off" )+"\n";
#ifdef __DSLIB__
    ret += "Keepalive mode: \t"+ ( this_player()->GetProperty("keepalive") 
            ? this_player()->GetProperty("keepalive") : "off" )+"\n";
#endif

    if(creatorp(this_player())){ 
        ret += "Homedir: \t\t"+user_path(this_player())+"\n";
        if(this_player()->GetParanoia("homeroom")){
            ret += "Homeroom: \t\t"+this_player()->GetParanoia("homeroom")+"\n";
        }
        ret += "Debug mode: \t\t"+ ( (this_player()->GetProperty("debug")) ? "on" : "off" )+"\n";
        ret += "Godmode: \t\t"+ ( (this_player()->GetGodMode()) ? "on" : "off" )+"\n";
        ret += "Wizvision: \t\t"+ ( (this_player()->GetWizVision()) ? "on" : "off" )+"\n";
#if GRID
        ret += "Showgrid: \t\t"+ ( (this_player()->GetVisibleGrid()) ? "on" : "off" )+"\n";
        ret += "Wizmap mode: \t\t"+ ( this_player()->GetProperty("wizmapping") ? "on" : "off" )+"\n";
        ret += "Noclip mode: \t\t"+ ( this_player()->GetProperty("noclip") ? "on" : "off" )+"\n";
        ret += "Anchor: \t\t"+ ( this_player()->GetAnchored() ? "on" : "off" )+"\n";
#endif
    }
    if(replee){
        ret += "Reply target: \t\t"+replee+"\n";
    }
    tmp = sort_array(explode(ret, "\n"),1);
    ret = implode(tmp, "\n");
    write(ret);
    return 1;
}
int main()
{
double array1[MAXSIZE],array2[MAXSIZE],array3[MAXSIZE*2];
int size1,size2,location;
double value;

printf("Enter the 1st array terminated by a CTRL-D:\n");
size1=get_array(array1);

printf("\nYou entered these numbers:\n");
disp_array(size1,array1);
sort_array(size1,array1);
printf("\nIn descending order, these are the number you entered:\n");
disp_array(size1,array1);

printf("\n\nEnter the 2nd array terminated by a CTRL-D:\n");
size2=get_array(array2);
printf("\nYou entered these numbers:\n");
disp_array(size2,array2);
sort_array(size2,array2);
printf("\nIn descending order, these are the number you entered:\n");
disp_array(size2,array2);


merge(size1,array1,size2,array2,array3);
printf("\nThese are the numbers you entered, merged and sorted:\n");
disp_array(size1+size2,array3);

printf("\nEnter value to locate (CTRL-D to end): ");
while (scanf("%lf",&value)!=EOF)
	{
	location=search(size1+size2,array3,value);
	if (location==-1)
		printf("Could not find %lf in the list.\n",value);
	else
		printf("Value: %lf was found at location: %i\n",
		                    array3[location],location+1);

   printf("Enter value to locate: ");
   } 

printf("\n");

return 0;

}
void union_oper(char *ptr, char key[MAX_KEY], entry *entryHead) {
	int keysLength = 1;
	char *keys = get_keys(ptr, key, &keysLength);
	
	if (keysLength == 1) {
		printf("invalid input\n");
		free(keys);
		return;
	}
	
	entry *lastEntry = get_entry(entryHead, &keys[MAX_KEY*(keysLength - 1)]);
	if (lastEntry == NULL) {
		printf("no such key\n");
		free(keys);
		return;
	}
	int *processedValues = get_values_copy(lastEntry->values, lastEntry->length);
	int valuesLength = lastEntry->length;
	
	for (int i = keysLength - 2; i >= 0; i--) {
		entry *first = get_entry(entryHead, &keys[MAX_KEY*i]);
		if (first == NULL) {
			printf("no such key\n");
			return;
		}
		
		processedValues = (int *) realloc(processedValues, sizeof(int)*(valuesLength + first->length));
		int counter = 0;
		for (int i = valuesLength; i < valuesLength + first->length; i++) {
			processedValues[i] = first->values[counter];
			counter++;
		}
		valuesLength = valuesLength + first->length;
	}

	free(keys);
	
	if (valuesLength == 0) {
		printf("[]\n");
		free(processedValues);
		return;
	}
	
	sort_array(processedValues, valuesLength);
	
	int tempLength = 0;
	int *uniqProcessedValues = get_unique_array(processedValues, valuesLength, &tempLength);
	
	printf("[");
	for (int i = 0; i < tempLength - 1; i++) {
		printf("%d ", uniqProcessedValues[i]);	
	}
	printf("%d]\n", uniqProcessedValues[tempLength - 1]);
	
	free(uniqProcessedValues);
	free(processedValues);
}		
Exemple #9
0
int cmd_groups(string str) {
      string label;

     mapping groups=master()->query_groups();
      string *lists=sort_array(keys(groups),-1);
      string *club;
         int countera=sizeof(lists);

    if(!str) {

       for(countera;countera>0;countera--) {
           club=({});
          label=lists[countera-1];
           club=sort_array((groups[label]),1);

         write("%^GREEN%^%^BOLD%^Group name :: %^RED%^%^BOLD%^"+label+"%^CYAN%^%^BOLD%^");
         write(format_page(club,4));
                   } // End for loop
         return 1; } // end listing of ALL groups if no str is entered
Exemple #10
0
int cmd(string str){
    int i, cols = 2;
    string *ret, *tmp;
    if(str) i = atoi(str);
    if(i) cols = i;
    tmp = sort_array(FUNCTION_D->GetFunctions(), 1);
    ret = explode(format_page(tmp, cols), "\n");
    this_player()->eventPage(ret);
    return 1;
}
Exemple #11
0
int main(int argc,  char *argv[])
{
	int array[M];

	init_array(array, M);
	print_array(array, M);
	sort_array(array, M);
	print_array(array, M);
	
    return 0;
} 
Exemple #12
0
int main(object me, string arg)
{
	string *list;

	write(MUD_NAME + "目前的管理有:\n");
	list = sort_array(SECURITY_D->query_wizlist(), 1);
	for(int i=0; i<sizeof(list); i++)
		printf("%-15s%c", list[i],  (i%5==4) ? '\n' : ' ');
	write("\n");
	return 1;
}
//sorts values in ascending order
void sort(char key[MAX_KEY], entry *entryHead) {
	entry *chosenEntry = get_entry(entryHead, key);
	if (chosenEntry == NULL) {
		printf("no such key\n");
		return;
	}
	else {
		printf("ok\n");	
	}
	sort_array(chosenEntry->values, chosenEntry->length);
}
int main(int argc, const char *argv[])
{
    int array[M][N];
    int *ptr = &array[0][0];
    init_array(ptr , M*N);
    printf_array(ptr , M*N);
    getchar();
    sort_array(ptr , 0 ,M*N-1);
    printf_array(ptr , M*N);
    return 0;
}
Exemple #15
0
int main (int argc, char **argv)
{
    int array_size;
    struct kindergarden *children;
    children = (struct kindergarden*)malloc(max_base*sizeof(struct kindergarden));
    check_help(argc, argv);
    array_size = init_array(children);
    sort_array(children, array_size);
    search_illness(children, array_size, argv);
    free(children);
    return 0;
}
Exemple #16
0
int		sort(void)
{
  int		*arr;

  arr = malloc(sizeof(int) * (NB_VALUES + 1));
  if (!arr)
    return (ERROR);
  init_array(arr);
  disp_array(arr, 0);
  sort_array(arr);
  disp_array(arr, 1);
  return (SUCESS);
}
Exemple #17
0
int main(int argc, char *argv[]) {
  struct tnode *root = NULL;
  char word[MAXWORD];
  while(getword(word, MAXWORD) != EOF) {
    //printf("%s\n", word);
    if(isalpha(word[0]))
      root = addtree(root, word);
  }
  tree2array(root);
  sort_array();
  print_array();
  return 0;
}
Exemple #18
0
int do_purge_wizards(int day, int flag)
{
    int i, wiz_cnt, count;
    string *wiz;
    mixed info;

    wiz = sort_array(SECURITY_D->query_wizlist(), 1);
    seteuid(getuid());
    write("\n*** 整理巫师储存档中,请稍候.... ***\n");
    count=0;
    wiz_cnt=0;
    for(i=0; i<sizeof(wiz); i++)
    {
        wiz_cnt++;
        if(file_size(DATA_DIR + "login/" + wiz[i][0..0] + "/" + wiz[i] + __SAVE_EXTENSION__)<0 )
        {
            if(flag)
                SECURITY_D->set_player(wiz[i]);
            count++;
            write(wiz[i]+" : "+SECURITY_D->get_status(wiz[i])+" 早已不存在。\n");
            continue;
        }

        if(SECURITY_D->get_status(wiz[i])=="(manager)" || SECURITY_D->get_status(wiz[i])=="(guest)" || SECURITY_D->get_status(wiz[i])=="(admin)" || SECURITY_D->get_status(wiz[i])=="(arch)")
            continue;

        info = stat(DATA_DIR + "login/" + wiz[i][0..0] + "/" + wiz[i] + __SAVE_EXTENSION__);
        if( (time()-(int)info[1])/86400 >= day ) {
            count ++;
            write(wiz[i]+" : "+SECURITY_D->get_status(wiz[i])+" 已经有 "+(time()-(int)info[1])/86400+" 天没上线。\n");
            if(flag)
            {
                SECURITY_D->set_player(wiz[i]);
                rm(DATA_DIR + "login/" + wiz[i][0..0] + "/" + wiz[i] + __SAVE_EXTENSION__);
                rm(DATA_DIR + "user/" + wiz[i][0..0] + "/" + wiz[i] + __SAVE_EXTENSION__);
            }
        }
    }
    write("\n\n原来总共有 " + wiz_cnt + " 位巫师。\n");
    write( count + " 个超过 " + day + " 天未上线的巫师被清除掉了。\n");
    write("现在总共有 " + (wiz_cnt - count) + " 位巫师。\n");
    if(flag)
        log_file("static/PURGE_WIZ", sprintf("[%s] %s cleaned up %d wizards\n
                                             \t\t who didn't login for more than %d days\n
                                             \t\t Resulting statistics: %d wizards remaining.\n",
                                             ctime(time())[0..15], geteuid(this_player(1)), count, day, wiz_cnt - count));


    return 1;
}
Exemple #19
0
int main( object me, string str )
{
	object  *user;
	if( !str )
		if( me->query("clan") )
			str = me->query("clan/name");
                else
                        return help(me);

        user = filter_array(users(), "filter_clan", this_object(), str);
        user = sort_array(user, "sort_exp",  this_object());
	second( user , str );
	return 1;
}
Exemple #20
0
int cmd(string str){
    string *raw_array;
    string *grps = groups();
    string ret = "";
    PLAYERS_D->CompileCreList();
    raw_array = sort_array(PLAYERS_D->GetCreatorList(),1);
    foreach(string wiz in raw_array){
        string tmp = wiz;
        foreach(string group in grps){
            if(member_group(wiz, group)) tmp += " "+group+",";
        }
        if(last(tmp,1) == ",") tmp = truncate(tmp,1);
        ret += capitalize(tmp)+"\n";
    }
Exemple #21
0
int main(int argc,char **argv)
{

  int arr[ARRAY_SIZE];
  memset(arr,0,sizeof(int) * ARRAY_SIZE);

  unsigned int i=0;
  for(i=0;i<ARRAY_SIZE;i++){

    arr[i] = i%4;
  }
  
  sort_array(arr);
  
  return 0;
}
Exemple #22
0
int main()
{

	FILE *fp;
	int n, num, pos, *b, *a;
	char c;



	//------- INSERCION DE DATOS EN EL ARREGLO ----------- //
	printf("\nSorting an array... ");
	validate_int_read(&n, "SIZE:");
	b = malloc (sizeof(int) * n);
	read_rand_array(b, n);
	a = b;

	// for (i = 0; i < n; i++)
	// 	scanf("%d", &a[i]);

	// -------- IMPRESION EN PANTALLA DEL ARREGLO DE DATOS DESORDENADO ---- //
	printf("\nBEFORE:\n");
	print_int_array(a, n);


	// ------ PETICION AL USUARIO DEL METODO A UTILIZAR PARA ORDENAR ------- //
	sort_array(a, n);

	// -------- IMPRESION EN PANTALLA DEL ARREGLO DE DATOS DESORDENADO ---- //
	printf("\nAFTER:\n");
	print_int_array(a, n);

	// -------- BUSQUEDA BINARIA //
	printf("\n\nSearching in the array... ");
	validate_int_read(&num, "NUMBER:");

	pos = search_in_array(a, n, num);


	printf("\n\nWriting in file... ");
	write_results_file(fp, a, b, num, pos, n);

	// fclose(fp);

	return 0;
}
Exemple #23
0
Fichier : 91.c Projet : shixv/test
int main(void)
{
	char* my_array[] = { "aaaaa", "cccc", "bbbb", "11111" };

	int len = sizeof(my_array) / sizeof(my_array[0]);

	printf("排序之前\n");
	print_array(my_array, len);



	sort_array(my_array, len);


	printf("排序之后\n");
	print_array(my_array, len);

	return 0;
}
Exemple #24
0
int main(int argc, char* argv[])
{
	int array_size;
	printf("Enter the array size: ");
	scanf("%d", &array_size);
	printf("\n\n");

	int *int_array = (int*)malloc(array_size, sizeof(int));

	print_array(int_array, array_size);

	sort_array(int_array, array_size);

	print_array(int_array, array_size);

	printf("\n\n");

	return 0;
}
Exemple #25
0
int main(){
  FILE *data = fopen("data", "r");
  if(data != NULL){
    int *stuff, n;
    fscanf(data,"%i", &n);
    stuff = (int*) malloc(n*sizeof(int));
    if(stuff !=NULL){
       int i;
       for(i=0; i<n; i++){
         fscanf(data, "\n%i", stuff+i);
       }
       print_array(stuff, n);
       sort_array(stuff, n);
       print_array(stuff, n);
       if(!fclose(data) && (data = fopen("data", "w")) != NULL){
         for(i=0; i<n; i++){
           if(!fprintf( data, "%i\n", stuff[i])){
             return 4;
           }
         }
         if(fclose(data)){
           return 5;
         }
         else{
           free(stuff);
           return 0;
         }
       }
       else{
         return 3;
       }
    }
    else{
      return 2;
    }
  }
  else{
    return 1;
  }
}
Exemple #26
0
string finger_all() {
    object *who, link;
    int i, j;
    string msg;

    who = users();
    who = filter_array(who, "filter_users", this_object());

    who = sort_array(who, "sort_users", this_object());
    j = who ? sizeof(who) : 0;

    msg = LINE1;
    if (j == 0) {
	msg += "[" + capitalize(mud_name()) + "] No one is presently " +
	"connected (" + ctime(time()) + ").\n";
    } else {
	msg += "[" + capitalize(mud_name()) + "] " + j +
	(j == 1 ? " user" : " users") + " " +
	(j == 1 ? "is " : "are ") + "presently connected (" +
	ctime(time()) + ").\n";
	msg += LINE2;
	msg += sprintf("%-12s%-20s%-14s%-7s%-21s", "Login", "Real Name",
	  "Position", "Idle", "Where\n");
	msg += LINE2;
    }
    for (i = 0; i < j; i++) {
	link = (object)who[i]->query_link();
	if (!link || !link->RNAME)
	    continue;

	msg += sprintf("%-12s%-20s%-14s%-7s%-21s",
	  capitalize((string)link->NAME),
	  capitalize(extract((string)link->RNAME, 0, 18)),
	  capitalize((string)DOMAIN_D->query_domain_level(link)),
	  query_idle_string(who[i], 0),
	  extract(query_ip_name(who[i]), 0, 20) + "\n");
    }

    return msg + LINE1;
}
Exemple #27
0
/*
 * Function name: create
 * Description  : Called upon initialization to read the adverbs into
 *                memory.
 */
nomask void
create()
{
    string *lines;
    string adverb;
    string replacement;
    int    index = -1;
    int    size;

    setuid();
    seteuid(getuid());

    /* Read the adverbs-file if possible. */
    if (file_size(ADVERB_SAVE_FILE) > 0)
    {
	adverbs = sort_array(explode(read_file(ADVERB_SAVE_FILE), "\n"));
	adverbs_size = sizeof(adverbs);
    }

    if (!adverbs_size)
    {
        adverbs = DEFAULT_ADVERB_ARRAY;
        adverbs_size = sizeof(adverbs);
    }

    /* Read the replacement adverbs-file if possible. */
    if (file_size(ADVERB_REPLACEMENT_SAVE_FILE) > 0)
    {
        lines = explode(read_file(ADVERB_REPLACEMENT_SAVE_FILE), "\n");
        size = sizeof(lines);
        while(++index < size)
        {
            if (sscanf(lines[index], "%s:%s", adverb, replacement) == 2)
            {
                adverb_replacements[adverb] = replacement;
            }
        }
    }
}
Exemple #28
0
bool
iterative (int* array, int size, int value)//O(log n)
{
  if (NULL == array || size <= 0)
    return false;
  sort_array (array, size);
  int mid = size / 2;
  int min = 0;
  int max = size - 1;
  int temp = 0;
  if (array[min] == value || array[max] == value)
    return true;
  while (max >= min)
    {
      if (value > array[mid])
        {
          min = mid;
          mid = (min + max) / 2;
          if (temp == min)
            {
              return false;
            }
          temp = min;
        }
      if (value < array[mid])
        {
          max = mid;
          mid = (min + max) / 2;
          if (temp == max)
            {
              return false;
            }
          temp = max;
        }
      if (value == array[mid])
        return true;
    }
  return false;
}
Exemple #29
0
int list_array(string str)
{
    int i,j=0;
    int n;
    object *glist;
    glist=users();
    n=sizeof(glist);
    sort_array(glist,"list_skill",this_object());
    message_vision("风雷帮能力排行榜\n",this_player());
    message_vision("--------------\n",this_player());
    for(i=n-1; i>0; i--)
    {
        if(glist[i]->query("clam")=="风雷帮")
        {
            j++;
            message_vision("第"+chinese_number(j)+"名是"+    glist[i]->name()+"\n",this_player());

        }
    }

    return 1;
}
Exemple #30
0
int telling1 (object who)
{
  int size = sizeof(obstacles);
  string *names = keys(obstacles);
  string *strs = allocate (size);
  int nb = 0;
  int i;

  for (i = 0; i < size; i++)
  {
    strs[i] = "none";
  }

  for (i = 0; i < size; i++)
  {
    if (who->query("obstacle/"+names[i])=="done")
    {
      strs[nb] = obstacles[names[i]];
      nb++;
    }
  }

  if (nb == 0)
  {
    write (name+"尚未西行求取真经。\n");
  }
  else
  {
    write (name+"西行求取真经已过了"+chinese_number(nb)+"关:\n");
    who->set("obstacle/number",nb);
    strs = (string *)sort_array (strs, 1);
    for (i = 0; i < nb; i++)
    {
      write ("    "+strs[i]+"\n");
    }
  }
  return 1;
}