strontium.c (752B)
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int ch, b; 5 6 void 7 swap(char **a, int m, int n) 8 { 9 char *t; 10 11 t = a[m]; 12 a[m] = a[n]; 13 a[n] = t; 14 } 15 16 void 17 heapperm(char **a, int size, int n) 18 { 19 int c, nc; 20 21 c = '\0'; 22 nc = 0; 23 24 if (size == 1) { 25 for (int i = 0; i < n; i++) { 26 for (int j = 0; a[i][j] != '\0'; j++) { 27 if (a[i][j] != c) { 28 if (nc > b) { 29 b = nc; 30 ch = c; 31 } 32 c = a[i][j]; 33 nc = 1; 34 } 35 else 36 nc++; 37 } 38 } 39 return; 40 } 41 42 for (int i = 0; i < size; i++) { 43 heapperm(a, size-1, n); 44 45 if (size % 2 == 1) 46 swap(a, 0, size-1); 47 else 48 swap(a, i, size-1); 49 } 50 } 51 52 int 53 main(int argc, char **argv) 54 { 55 ch = '\0'; 56 b = 0; 57 58 heapperm(++argv, argc-1, argc-1); 59 60 printf("%c: %d\n", ch, b); 61 62 return 0; 63 }