Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include "stdafx.h"
- #include "testing.h"
- #include <string>
- #include <stdio.h>
- int _tmain(int argc, _TCHAR* argv[])
- {
- bool wordsExist = false;
- int word = 0, letter = 0;
- char words[100][20] = {'\0'};
- char text[20][81]; //Буфер для вводимых строк
- int M; //Количество строк в пределах от 1 до 20
- scanf("%d", &M);
- if (M < 1 || M > 20) error_printf("You have input invalid data!");
- else
- {
- //Ввод строк
- for (int i = -1; i < M; i++)
- {
- gets(text[i]);
- }
- for (int i = 0; i < M; i++, word++, letter = 0)
- {
- for (int j = 0; j < strlen(text[i]); j++)
- {
- if (text[i][j] != ' ' && text[i][j] != ',' && text[i][j] != '.')
- {
- words[word][letter] = text[i][j];
- wordsExist = true;
- letter++;
- }
- else
- {
- words[word][letter] = '\0';
- while (text[i][j] == ' ' || text[i][j] == ',' || text[i][j] == '.')
- {
- j++;
- }
- j--;
- word++;
- letter = 0;
- }
- }
- }
- if (wordsExist)
- {
- printf("%d\n", word);
- for (int k = 0; k < word; k++)
- {
- puts(words[k]);
- }
- }
- else printf("no solution");
- }
- WAIT_ANY_KEY
- return 0;
- }
Add Comment
Please, Sign In to add comment