kokusz19

2017.04.19.Azonos karakterek(A)

May 29th, 2017
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. //https://www.inf.unideb.hu/progcont/100195/exercises.html?pid=201023
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. int foo(char *sor)
  7. {
  8. int maxdb=0, db=1, i, j;
  9. if(strlen(sor)==1)
  10. return 1;
  11. for(i=0;i<strlen(sor)-1;i++)
  12. {
  13. for(j=1;j<strlen(sor);j++)
  14. {
  15. if(sor[i] == sor[j])
  16. {
  17. db++;
  18. }
  19. if(maxdb<db)
  20. {
  21. maxdb=db;
  22. }
  23. }
  24. db=0;
  25. }
  26. return maxdb;
  27. }
  28.  
  29. int main()
  30. {
  31. char line[100];
  32. while (gets(line) != NULL)
  33. printf("%d\n", foo(line));
  34. return EXIT_SUCCESS;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment