?? arugroup.c
字號(hào):
/*
Copyright (c) 2003, Dan Kranz and Arnold Rom
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
* The names of its contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <roots.h>
/* ############################################################################# */
/* # UGROUP (FIRST,LNEXTL,LFRSTL,LFRSTG,NGROUP) # */
/* # ------------------------------------------ # */
/* # UGROUP processes the output list generated by UQSORT. # */
/* # # */
/* # UGROUP converts UQSORT's output list to a standard COLECT list # */
/* # structure. See ROOTS operations COLECT and MCOLCT. # */
/* # # */
/* # The arguments are as follows: # */
/* # # */
/* # FIRST,LNEXTL,LFRSTL - are input to UGROUP. these parameters are output # */
/* # from UQSORT. See ROOTS operation UQSORT. # */
/* # # */
/* # LFRSTG,NGROUP - are output from UGROUP. In particular, UGROUP # */
/* # severs the input chain FIRST,LNEXTL. Each input # */
/* # member yields a distinct output group. Input # */
/* # clone sublists LFRSTL(L),LNEXTL are linked to # */
/* # their respective ancestors. # */
/* # # */
/* # NGROUP - is determined by UGROUP and equals the total # */
/* # number of output groups; i.e. LFRSTG(g),LNEXTL # */
/* # defines a distinct sublist for all g's ranging # */
/* # from 1 to NGROUP. # */
/* # # */
/* # UQSORT/UGROUP can be used instead of the sequence: # */
/* # CHSORT/LIST1/MCOLCT. # */
/* ############################################################################# */
/* small internal routines */
static void sos(void) {RootsSOS("ugroup sos exit\n"); abort();}
void ugroup(
long *first,
unsigned short *lnextl,
unsigned short *lfrstl,
unsigned short *lfrstg,
long *ngroup
)
/* --------------------------------------------------------- */
{ /* ugroup START */
/* --------------------------------------------------------- */
/* local data */
unsigned short q,group=0,next;
long guard=MAXLIN;
--lnextl; --lfrstl; --lfrstg;
for(q=(unsigned short)(*first); q>0; q=next)
{
if(!guard--)sos();
group++;
*(lfrstg+group)=q;
next=*(lnextl+q);
*(lnextl+q)=*(lfrstl+q);
}
*ngroup=group;
return;
/* --------------------------------------------------------- */
} /* ugroup END */
/* --------------------------------------------------------- */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -