Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h>
- int main(void)
- {
- int c, count, len1, flag, nw, status;
- setlocale(LC_ALL, "rus");
- count = 0; // счёстчик символов в слове
- len1 = 0; // длина первого слова
- flag = 1; // условие, когда слова одинаковой длины
- nw = 0; // количество слов
- status = 0; // признак нахождения в слове
- printf("Введите строку: \n");
- while ((c = getchar()) != '0')
- {
- if ((c == ' ') || (c == ',') || (c == '\n') || (c == '.') || (c == '\t'))
- {
- status = 0;
- }
- else if (status == 0)
- {
- status = 1;
- nw++;
- }
- if ((c != ' ') && (c != ',') && (c != '\n') && (c != '.') && (c != '\t'))
- count++;
- else
- {
- if (len1 == 0)
- {
- len1 = count;
- }
- if ((len1 != count)&& (count != 0))
- {
- flag = 0;
- }
- count = 0;
- }
- }
- if ((len1 != count) && (count != 0))
- {
- flag = 0;
- }
- if ((flag == 1) && (nw > 1))
- printf("Слова одинаковой длины\n");
- else if (nw <= 1)
- printf("Введите не менее двух слов\n");
- else if (flag == 0)
- printf("Слова разной длины\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement