Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <time.h>
  2. #include <iostream>
  3. #include <math.h>
  4. #include <windows.h>
  5. #include <stdlib.h>
  6.  
  7. using namespace std;
  8.  
  9. char *word(char *str)
  10. {
  11. int b,l=1,i,k=0,kil,u;
  12. char q,max;
  13. int w;
  14. while(l<strlen(str))
  15. {
  16. i=strlen(str)-1;
  17. w=0;
  18. while(i>=0)
  19. {
  20. if(str[strlen(str)-l]==str[i])
  21. {
  22. q=str[i];
  23. w=w+1;
  24. k=k+1;
  25. }
  26.  
  27. i=i-1;
  28.  
  29. if(k==1)
  30. u=w;
  31.  
  32.  
  33. }
  34. if(w>=u)
  35. {
  36. max=q;
  37. kil=w;
  38. }
  39. l=l+1;
  40.  
  41. }
  42. return word;
  43. }
  44. int main()
  45. {
  46. int b,l=1,i,k=0,kil,u;
  47. const int n=256;
  48. char str[n];
  49. char *f;
  50. char q,max;
  51. int w;
  52. cout<<"Введіть слово"<<endl;
  53. gets(str);
  54.  
  55. f=word(str);
  56.  
  57. word(&str);
  58.  
  59. cout<<endl<<"Кількість повторень="<<kil<<endl<<"Літера яка найчастіше повторюється"<<max;
  60.  
  61. return 0;
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement