fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. int has26(const char *p) {
  5. int c, count[26] = {0};
  6. for (; c = tolower(*p); p++) if (isalpha(c)) count[c - 'a']++;
  7. for (c = 'a'; c <= 'z'; c++) if (count[c - 'a'] < 1) return 0;
  8. return 1;
  9. }
  10. const char *f(const char **lines, int n) {
  11. const char *found = 0;
  12. int i, len, minlen;
  13. for (i = 0; i < n; i++)
  14. if (has26(lines[i]))
  15. if (!found)
  16. found = lines[i], minlen = strlen(lines[i]);
  17. else if ((len = strlen(lines[i])) < minlen)
  18. found = lines[i], minlen = len;
  19. return found;
  20. }
  21. int main() {
  22. const char *lines[] = {
  23. "The quick brown fox jumps over a lazy dog."
  24. , "The jay, pig, fox, zebra and my wolves quack!"
  25. , "Pack my box with seven dozen liquor jugs."
  26. , "The horse, pig, fox, zebra and my wolves quack!"
  27. , "Jackdaws love my small sphinx of quartz."
  28. , "Jackdaws love my big sphinx of quartz."
  29. , "The quick brown fox jumps over a lazy cat."
  30. , "Pack my box with five dozen liquor jugs."
  31. };
  32. puts(f(lines, sizeof lines / sizeof *lines));
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Jackdaws love my big sphinx of quartz.