Article View: ch.comp.os.linux
Article #19745So
From: Paul Baer
Date: Sat, 04 Dec 1999 00:00
Date: Sat, 04 Dec 1999 00:00
54 lines
1604 bytes
1604 bytes
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
static int t[33] = {
4, 3, 2, 7, 6, 5, 4, 3, 2, 7,
6, 5, 4, 3, 2, 7, 6, 5, 4, 3,
2, 7, 6, 5, 4, 3, 2, 7, 6, 5,
4 , 3, 2
};
static int m[10][10] = {
{ 0, 9, 4, 6, 8, 2, 7, 1, 3, 5 },
{ 9, 4, 6, 8, 2, 7, 1, 3, 5, 0 },
{ 4, 6, 8, 2, 7, 1, 3, 5, 0, 9 },
{ 6, 8, 2, 7, 1, 3, 5, 0, 9, 4 },
{ 8, 2, 7, 1, 3, 5, 0, 9, 4, 6 },
{ 2, 7, 1, 3, 5, 0, 9, 4, 6, 8 },
{ 7, 1, 3, 5, 0, 9, 4, 6, 8, 2 },
{ 1, 3, 5, 0, 9, 4, 6, 8, 2, 7 },
{ 3, 5, 0, 9, 4, 6, 8, 2, 7, 1 },
{ 5, 0, 9, 4, 6, 8, 2, 7, 1, 3 }
};
int mod10(s)
char *s;
{
char c, *p;
int u = 0;
p = s;
while (isdigit(*p))
u = m[u][*p++ - '0'];
return(b[u]);
}
int mod11(s)
char *s;
{
char c, *p;
int r = 0;
int i = 0;
p = s;
while (isdigit(*p)) {
r += (t[i++] * (*p++- '0'));
}
r = 11 - (r % 11);
if ( r == 11)
r = 0;
return r;
}
Technical Details
Message-ID:
<o8sb28.j9u.ln@lr.cbf.ch>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f4b73,d328087131a79e33,start X-Google-Attributes: gidf4b73,public From: "Paul Baer" <pbb@cbf.ch> Subject: So Date: 1999/12/04 Message-ID: <o8sb28.j9u.ln@lr.cbf.ch> X-Deja-AN: 556640259 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: news@ip-plus.net X-Trace: pollux.ip-plus.net 944338203 824 195.216.80.33 (4 Dec 1999 20:10:03 GMT) Organization: Swisscom IP+ (post doesn't reflect views of Swisscom) X-MSMail-Priority: Normal NNTP-Posting-Date: 4 Dec 1999 20:10:03 GMT Newsgroups: ch.comp.os.linux