Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void main()
  5. {
  6. int n;
  7. do
  8. {
  9. system("chcp 1251");
  10. int input_word[40];
  11. int result_word[40];
  12. int povtor_lit = 0, max_povtor_lit = 0;
  13. int lit, sym = ' ', i = 0, q = 0;
  14. int arr[40];
  15.  
  16. printf("\n\tВведіть літеру - ");
  17. lit = getchar();
  18. while (getchar() != '\n') {}
  19.  
  20. printf("\n\tВведіть речення - ");
  21. while (sym != '\n') {
  22. i = 0;
  23. povtor_lit = 0;
  24. while ((sym = getchar()) != ' ' && sym != '\n') {
  25. input_word[i] = sym;
  26. if (sym == lit || sym + 32 == lit) {
  27. povtor_lit++;
  28. }
  29. i++;
  30. }
  31. if (povtor_lit > max_povtor_lit) {
  32. max_povtor_lit = povtor_lit;
  33. q = 0;
  34. for (; q < i; q++) {
  35. result_word[q] = input_word[q];
  36. }
  37. }
  38. }
  39. printf("\n\tЛітера %c повторюється %d разів у слові - ", lit, max_povtor_lit);
  40. for (i = 0; i < q; i++) {
  41. printf("%c", result_word[i]);
  42. }
  43. getchar();
  44. printf("\n\tПродовжити? 1/0\t", &n);
  45. scanf_s("%d", &n);
  46. scanf_s("%*c");
  47. } while (n == 1);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement