Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void main()
- {
- int n;
- do
- {
- system("chcp 1251");
- int input_word[40];
- int result_word[40];
- int povtor_lit = 0, max_povtor_lit = 0;
- int lit, sym = ' ', i = 0, q = 0;
- int arr[40];
- printf("\n\tВведіть літеру - ");
- lit = getchar();
- while (getchar() != '\n') {}
- printf("\n\tВведіть речення - ");
- while (sym != '\n') {
- i = 0;
- povtor_lit = 0;
- while ((sym = getchar()) != ' ' && sym != '\n') {
- input_word[i] = sym;
- if (sym == lit || sym + 32 == lit) {
- povtor_lit++;
- }
- i++;
- }
- if (povtor_lit > max_povtor_lit) {
- max_povtor_lit = povtor_lit;
- q = 0;
- for (; q < i; q++) {
- result_word[q] = input_word[q];
- }
- }
- }
- printf("\n\tЛітера %c повторюється %d разів у слові - ", lit, max_povtor_lit);
- for (i = 0; i < q; i++) {
- printf("%c", result_word[i]);
- }
- getchar();
- printf("\n\tПродовжити? 1/0\t", &n);
- scanf_s("%d", &n);
- scanf_s("%*c");
- } while (n == 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement