nn.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #define ABS(x,y) (((x) > (y))? x - y : y - x)
3 
4 main(ac, av)
5 int ac;
6 char **av;
7 {
8  int tmp, min = 1000000, lineno = 0, minline = 0, minmax = 1000000;
9  char s[BUFSIZ];
10 
11  if(ac < 3) {
12  printf("0\n");
13  exit();
14  }
15  if(ac == 3) minmax = atoi(av[2]);
16  while(gets(s) != NULL) {
17  lineno++;
18  tmp = hamming(s, av[1]);
19  if(min > tmp) {
20  min = tmp;
21  minline = lineno;
22  }
23  }
24  if(minmax > min)
25  printf("%d\n", minline);
26  else
27  printf("0\n");
28 }
29 
30 
31 hamming(s1, s2)
32 char *s1, *s2;
33 {
34  int i, j;
35  for(i = j = 0; i < 26; i++) {
36  j += ABS(s1[i], s2[i]);
37  }
38  return j;
39 }
40 
41 
#define min(x, y)
Definition: rmflags.c:17
#define ABS(x, y)
Definition: nn.c:2
short s
Definition: structsize.c:2
hamming(char *s1, char *s2)
Definition: nn.c:31
int lineno
Definition: eustags.c:168
#define NULL
Definition: transargv.c:8
main(int ac, char **av)
Definition: nn.c:4


euslisp
Author(s): Toshihiro Matsui
autogenerated on Mon Feb 28 2022 22:18:28