Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <stdio.h>
  4. #include <windows.h>
  5. #include <string.h>
  6.  
  7. void ab(char *s)
  8. {
  9. char *word, str[50], ser[50];
  10. int a = 1;
  11. strcpy(str, s);
  12. word = strtok(str, " ");
  13. do {
  14. strcpy(ser, str);
  15. _strrev(ser);
  16. a = strcmp(ser, str);
  17. if (a == 0) break;
  18. word = strtok(NULL, " ");
  19. } while (word);
  20. if (a == 0) printf("Tak, v stroci e polindromu.\n"); else printf("Ni, v strocs nemaye polindromiv.\n");
  21. }
  22.  
  23. void kil(char *s)
  24. {
  25.  
  26. char *word, str[50], *ser[50], *easy[50], *maxi = NULL;
  27. int a = 0, max = 0, mas[50];
  28. strcpy(str, s);
  29. word = strtok(str, " ");
  30. do {
  31. ser[a] = word;
  32. a++;
  33. word = strtok(NULL, " ");
  34. } while (word);
  35. for (int i = 0; i < a; i++) {
  36. int g = 0;
  37. for (int j = 0; j < a; j++) {
  38. if (strcmp(ser[i], ser[j]) == 0) g++;
  39. }
  40. if (g > max) {
  41. max = g;
  42. maxi = ser[i];
  43. }
  44.  
  45.  
  46. printf("Slovo (%s) povtoryuetsa (%i) raziv\n", ser[i], g);
  47.  
  48. }
  49. printf("Naibilshe (%s) sliv - (%i) \n", maxi, max);
  50.  
  51. for (int i = 0; i < a; i++) mas[i] = 1;
  52.  
  53. for (int i = 0; i < a; i++) {
  54. int g = 0;
  55. for (int j = 0; j < a; j++) {
  56. if (strcmp(ser[i], ser[j]) == 0) {
  57. g++;
  58. if (g > 1) mas[j] = 0;
  59. }
  60. }
  61. }
  62. int z = 0;
  63. for (int i = 0; i < a; i++) {
  64. if (mas[i] == 1) {
  65. easy[z] = ser[i];
  66. z++;
  67. }
  68. }
  69. printf("Slova bez povtoriv:");
  70. for (int i = 0; i < z; i++) {
  71. printf("%s ", easy[i]);
  72. }
  73. printf("\n");
  74.  
  75. char abc[27] = { "qwertyuiopasdfghjklzxcvbnm" };
  76.  
  77. for (int i = 0; i < 26; i++) {
  78. int g = 0;
  79. for (int j = 0; j < z; j++) {
  80. if (abc[i] == easy[j][0])g++;
  81. }
  82. if (g >= 1)printf("Na bukvu (%c) sliv (%i)\n", abc[i], g);
  83. }
  84. }
  85.  
  86.  
  87. int main()
  88. {
  89. char s[50];
  90. gets_s(s);
  91. kil(s);
  92. puts(s);
  93. system("pause");
  94. return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement