File: LCM.c

package info (click to toggle)
qepcad 1.74%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,848 kB
  • sloc: ansic: 27,242; cpp: 2,995; makefile: 1,287; perl: 91
file content (27 lines) | stat: -rw-r--r-- 620 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*===========================================================================
                         t <- LCM(L,M)

List Common Member.

Inputs
   L,M:  arbitrary lists.

Output
   t:    1 if L and M have a common member, 0 otherwise.
===========================================================================*/
#include "qepcad.h"

Word LCM(Word L, Word M)
{
       Word a1,Lp,t;

Step1: /* Test whether any element of L belongs to M. */
       t = 0;
       Lp = L;
       while (Lp != NIL) {
	  ADV(Lp,&a1,&Lp);
	  if (MEMBER(a1,M)) { t = 1; goto Return; } }

Return: /* Prepare for return. */
       return(t);
}