Guest User

Untitled

a guest
Nov 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7. char words[50], max[50], longest[50], dupe[50];
  8. int n, c, x, dupepos;
  9. dupe[0] = '';
  10. max[0] = '';
  11. longest[0] = '';
  12. scanf("%d", &n);
  13. for(c = 0; c <= n; c++) {
  14. fgets(words, 50, stdin);
  15. x = strcmp(max, words);
  16. if(strlen(words) > strlen(longest)) strcpy(longest, words);
  17. if(x < 0) strcpy(max, words);
  18. }
  19. printf("Longest: %s", longest);
  20. printf("Max: %s", max);
  21. // if(dupe == 0) printf("UNIQUE (no dupes)n");
  22. // else printf("First dupe found at position %d: %sn", dupepos, dupe);
  23. return 0;
  24. }
  25.  
  26. for(int c = 0; c < n; c++) {
  27. scanf("%d", &num);
  28. unique[num]++;
  29. if(unique[num] > 1 && dupe == 0) dupe = num;
  30. }
Add Comment
Please, Sign In to add comment